// 网络请求模块

// 基础配置
const BASE_URL = 'https://api.example.com'; // 实际开发中需要替换为真实的API地址
const TIMEOUT = 10000;

/**
 * 生成快客网球API签名
 * @param {Object} params - 请求参数
 * @param {string} appId - 应用ID，用于签名
 * @returns {string} 生成的API签名
 */
export function generateKuaiKeApiSignature(params, appId) {
  // 导入crypto-js用于MD5加密
  const CryptoJS = require('crypto-js');
  
  // 过滤特殊参数
  const filteredParams = {};
  for (const [key, value] of Object.entries(params)) {
    if (!['pfx', 'partner_key', 'sign', 'key'].includes(key) && value !== undefined && value !== null) {
      filteredParams[key] = value;
    }
  }
  
  // 对参数键名进行排序
  const sortedKeys = Object.keys(filteredParams).sort();
  
  // 拼接参数字符串
  const paramString = sortedKeys
    .map(key => `${key}=${filteredParams[key]}`)
    .join('&');
  
  // 添加key=appId
  const signString = paramString + '&key=' + appId;
  
  // MD5加密并转大写
  const signature = CryptoJS.MD5(signString).toString().toUpperCase();
  
  return signature;
}

/**
 * 封装uni.request
 * @param {Object} options - 请求配置
 * @returns {Promise} 请求Promise
 */
function request(options = {}) {
  // 设置默认配置
  const config = {
    url: '',
    method: 'GET',
    data: {},
    header: {
      'Content-Type': 'application/json'
    },
    timeout: TIMEOUT,
    ...options
  };
  
  // 完整URL
  if (!config.url.startsWith('http')) {
    config.url = BASE_URL + config.url;
  }
  // console.log("config",config);
  
  return new Promise((resolve, reject) => {
    uni.request({
      ...config,
      success: (res) => {
        // 处理响应
        if (res.statusCode === 200) {
          resolve(res.data);
        } else {
          reject(new Error(`请求失败: ${res.statusCode}`));
        }
      },
      fail: (err) => {
        // 处理错误
        reject(new Error(`网络错误: ${err.errMsg}`));
      }
    });
  });
}

/**
 * 获取Mteam网球(黄埔)场地预约设置
 * @param {Object} params - 查询参数 { startDate, endDate }
 * @returns {Promise} 请求Promise
 */
export function getMteamHuangPuVenueSettings(params = {}) {
  // 设置默认参数
  const defaultParams = {
    timezoneOffset: -480,
    access_token: '3af4f465cfdfb6240726201790c5970c',
    user_id: '9314459',
    box_id: '16156',
    language: 'zh_CN',
    api_version: '3',
    appId: 'wx255c5fad9593085d',
    id: '9003'
  };
  
  // 合并参数
  const requestParams = { ...defaultParams, ...params };
  
  // 格式化日期参数（如果存在）
  if (requestParams.startDate) {
    if (requestParams.startDate instanceof Date) {
      requestParams.startDate = requestParams.startDate.toString();
    }
  }
  if (requestParams.endDate) {
    if (requestParams.endDate instanceof Date) {
      requestParams.endDate = requestParams.endDate.toString();
    }
  }
  
  // 生成API签名
  const api_signature = generateKuaiKeApiSignature(requestParams, defaultParams.appId);
  requestParams.api_signature = api_signature;
  
  return new Promise((resolve, reject) => {
    uni.request({
      url: 'https://fc-mp-0c81a8be-aa9a-4fae-8d6c-54b797768401.next.bspapp.com/cloudfunctions/proxyRequest',
      method: 'POST',
      header: {
        'content-type': 'application/json'
      },
      data: {
        url: 'https://api2.iwod.cn/court/getSubCourtList',
        method: 'GET',
        params: requestParams
      },
      success: (res) => {
        if (res.statusCode === 200) {
          resolve(res.data.data);
        } else {
          reject(new Error(`请求失败: ${res.statusCode}`));
        }
      },
      fail: (err) => {
        reject(new Error(`网络错误: ${err.errMsg}`));
      }
    });
  });
}

/**
 * 获取瀚为网球场地预约设置
 * @param {Object} params - 查询参数 { startDate, endDate }
 * @returns {Promise} 请求Promise
 */
export function getHanWeiTennisVenueSettings(params = {}) {
  // 设置默认参数
  const defaultParams = {
    timezoneOffset: -480,
    access_token: '2b3a5978fd16d949c296280c5cb54ea1',
    user_id: '9314341',
    box_id: '9458',
    language: 'zh_CN',
    api_version: '3',
    appId: 'wx673161f76dbe64fd',
    id: '3982'
  };
  
  // 合并参数
  const requestParams = { ...defaultParams, ...params };
  
  // 格式化日期参数（如果存在）
  if (requestParams.startDate) {
    if (requestParams.startDate instanceof Date) {
      requestParams.startDate = requestParams.startDate.toISOString().split('T')[0];
    }
  }
  if (requestParams.endDate) {
    if (requestParams.endDate instanceof Date) {
      requestParams.endDate = requestParams.endDate.toISOString().split('T')[0];
    }
  }
  
  // 生成API签名
  const api_signature = generateKuaiKeApiSignature(requestParams, defaultParams.appId);
  requestParams.api_signature = api_signature;
  
  return new Promise((resolve, reject) => {
    uni.request({
      url: 'https://fc-mp-0c81a8be-aa9a-4fae-8d6c-54b797768401.next.bspapp.com/cloudfunctions/proxyRequest',
      method: 'POST',
      header: {
        'content-type': 'application/json'
      },
      data: {
        url: 'https://api2.iwod.cn/court/getSubCourtList',
        method: 'GET',
        params: requestParams
      },
      success: (res) => {
        if (res.statusCode === 200) {
          resolve(res.data.data);
        } else {
          reject(new Error(`请求失败: ${res.statusCode}`));
        }
      },
      fail: (err) => {
        reject(new Error(`网络错误: ${err.errMsg}`));
      }
    });
  });
}

/**
 * 获取Mteam网球(嘉禾广丰)场地预约设置
 * @param {Object} params - 查询参数 { startDate, endDate }
 * @returns {Promise} 请求Promise
 */
export function getMteamJiaHeGuangFengVenueSettings(params = {}) {
  // 设置默认参数
  const defaultParams = {
    timezoneOffset: -480,
    access_token: '3af4f465cfdfb6240726201790c5970c',
    user_id: 9314459,
    box_id: 15132,
    language: 'zh_CN',
    api_version: 3,
    appId: 'wx255c5fad9593085d',
    id: 8356
  };
  
  // 合并参数
  const requestParams = { ...defaultParams, ...params };
  
  // 格式化日期参数（如果存在）
  if (requestParams.startDate) {
    if (requestParams.startDate instanceof Date) {
      requestParams.startDate = requestParams.startDate.toString();
    }
  }
  
  if (requestParams.endDate) {
    if (requestParams.endDate instanceof Date) {
      requestParams.endDate = requestParams.endDate.toString();
    }
  }
  
  // 生成API签名
  requestParams.api_signature = generateKuaiKeApiSignature(requestParams, requestParams.appId);
  
  return new Promise((resolve, reject) => {
    uni.request({
      url: 'https://fc-mp-0c81a8be-aa9a-4fae-8d6c-54b797768401.next.bspapp.com/cloudfunctions/proxyRequest',
      method: 'POST',
      header: {
        'content-type': 'application/json'
      },
      data: {
        url: 'https://api2.iwod.cn/court/getSubCourtList',
        method: 'GET',
        params: requestParams
      },
      success: (res) => {
        if (res.statusCode === 200) {
          resolve(res.data.data);
        } else {
          reject(new Error(`请求失败: ${res.statusCode}`));
        }
      },
      fail: (err) => {
        reject(new Error(`网络错误: ${err.errMsg}`));
      }
    });
  });
}

/**
 * 获取云堡罗伦斯网球场地预约设置
 * @param {Object} params - 查询参数 { startDate, endDate }
 * @returns {Promise} 请求Promise
 */
export function getYunBaoLuoLunSiVenueSettings(params = {}) {
  // 设置默认参数
  const defaultParams = {
    timezoneOffset: -480,
    access_token: 'c4d20ab12ab5a996d9561979569427ba',
    user_id: '9253921',
    box_id: '15938',
    language: 'zh_CN',
    api_version: '3',
    appId: 'wxc4892bb6d243bb7a'
  };
  
  // 合并参数
  const requestParams = { ...defaultParams, ...params };
  
  // 格式化日期参数（如果存在）
  if (requestParams.startDate) {
    if (requestParams.startDate instanceof Date) {
      requestParams.startDate = requestParams.startDate.toString();
    }
  }
  if (requestParams.endDate) {
    if (requestParams.endDate instanceof Date) {
      requestParams.endDate = requestParams.endDate.toString();
    }
  }
  
 
  // 创建两个并行请求
  const requests = [
    // 第一个场地 id=9037
    new Promise((resolve, reject) => {
       // 生成API签名
  
      const params1 = { ...requestParams, id: '9037' };
      params1.api_signature = generateKuaiKeApiSignature(params1, requestParams.appId);

      uni.request({
        url: 'https://fc-mp-0c81a8be-aa9a-4fae-8d6c-54b797768401.next.bspapp.com/cloudfunctions/proxyRequest',
        method: 'POST',
        header: {
          'content-type': 'application/json'
        },
        data: {
          url: 'https://api2.iwod.cn/court/getSubCourtList',
          method: 'GET',
          params: params1
        },
        success: (res) => {
          if (res.statusCode === 200) {
            resolve(res.data.data);
          } else {
            reject(new Error(`请求失败: ${res.statusCode}`));
          }
        },
        fail: (err) => {
          reject(new Error(`网络错误: ${err.errMsg}`));
        }
      });
    }),
    
    // 第二个场地 id=9512
    new Promise((resolve, reject) => {
      const params2 = { ...requestParams, id: '9512' };
      params2.api_signature = generateKuaiKeApiSignature(params2, requestParams.appId);

      uni.request({
        url: 'https://fc-mp-0c81a8be-aa9a-4fae-8d6c-54b797768401.next.bspapp.com/cloudfunctions/proxyRequest',
        method: 'POST',
        header: {
          'content-type': 'application/json'
        },
        data: {
          url: 'https://api2.iwod.cn/court/getSubCourtList',
          method: 'GET',
          params: params2
        },
        success: (res) => {
          if (res.statusCode === 200) {
            resolve(res.data.data);
          } else {
            reject(new Error(`请求失败: ${res.statusCode}`));
          }
        },
        fail: (err) => {
          reject(new Error(`网络错误: ${err.errMsg}`));
        }
      });
    })
  ];
  
  // 等待所有请求完成并合并结果
  return Promise.all(requests).then(results => {
    const mergedData = {
      data: {
        data: {
          courtList: []
        }
      }
    };
    
    // 合并所有场地数据
    results.forEach(result => {
      if (result && result.data && result.data.data && result.data.data.courtList) {
        mergedData.data.data.courtList = mergedData.data.data.courtList.concat(result.data.data.courtList);
      }
    });
    
    return mergedData;
  });
}

/**
 * 获取全爱网球(荔湾店)场地预约设置
 * @param {Object} params - 查询参数 { startDate, endDate }
 * @returns {Promise} 请求Promise
 */
export function getQuanAiLiWanVenueSettings(params = {}) {
  // 设置默认参数
  const defaultParams = {
    timezoneOffset: -480,
    access_token: 'a6e0ed372445a0113013bb74ab6f92c9',
    user_id: '9310133',
    box_id: '13151',
    language: 'zh_CN',
    api_version: '3',
    appId: 'wxa23d17ffa705bd30'
  };
  
  // 合并参数
  const requestParams = { ...defaultParams, ...params };
  
  // 格式化日期参数（如果存在）
  if (requestParams.startDate) {
    if (requestParams.startDate instanceof Date) {
      requestParams.startDate = requestParams.startDate.toString();
    }
  }
  if (requestParams.endDate) {
    if (requestParams.endDate instanceof Date) {
      requestParams.endDate = requestParams.endDate.toString();
    }
  }
  
  // 创建两个请求，分别使用id=11022和id=11023
  const createRequest = (id) => {
    const paramsWithId = { ...requestParams, id };
    
    // 生成API签名
    const api_signature = generateKuaiKeApiSignature(paramsWithId, paramsWithId.appId);
    paramsWithId.api_signature = api_signature;
    
    return new Promise((resolve, reject) => {
      uni.request({
        url: 'https://fc-mp-0c81a8be-aa9a-4fae-8d6c-54b797768401.next.bspapp.com/cloudfunctions/proxyRequest',
        method: 'POST',
        header: {
          'content-type': 'application/json'
        },
        data: {
          url: 'https://api2.iwod.cn/court/getSubCourtList',
          method: 'GET',
          params: paramsWithId
        },
        success: (res) => {
          if (res.statusCode === 200) {
            resolve(res.data.data);
          } else {
            reject(new Error(`请求失败: ${res.statusCode}`));
          }
        },
        fail: (err) => {
          reject(new Error(`网络错误: ${err.errMsg}`));
        }
      });
    });
  };
  
  // 并行执行两个请求
  return Promise.all([
    createRequest(11022),
    createRequest(11023)
  ]);
}

/**
 * 获取青芸网球场地预约设置
 * @param {Object} params - 查询参数 { startDate, endDate }
 * @returns {Promise} 请求Promise
 */
export function getQingYunTennisVenueSettings(params = {}) {
  // 设置默认参数
  const defaultParams = {
    timezoneOffset: -480,
    access_token: 'b33cb6124df7b3af0eeeae79d0638504',
    user_id: '9254363',
    box_id: '10228',
    language: 'zh_CN',
    api_version: '3',
    appId: 'wx5ac7d00aa9fd734e',
    id: '4968'
  };
  
  // 合并参数
  const requestParams = { ...defaultParams, ...params };
  
  // 格式化日期参数（如果存在）
  if (requestParams.startDate) {
    if (requestParams.startDate instanceof Date) {
      requestParams.startDate = requestParams.startDate.toString();
    }
  }
  if (requestParams.endDate) {
    if (requestParams.endDate instanceof Date) {
      requestParams.endDate = requestParams.endDate.toString();
    }
  }
  
  // 生成API签名
  const api_signature = generateKuaiKeApiSignature(requestParams, defaultParams.appId);
  requestParams.api_signature = api_signature;
  
  return new Promise((resolve, reject) => {
    uni.request({
      url: 'https://fc-mp-0c81a8be-aa9a-4fae-8d6c-54b797768401.next.bspapp.com/cloudfunctions/proxyRequest',
      method: 'POST',
      header: {
        'content-type': 'application/json'
      },
      data: {
        url: 'https://api2.iwod.cn/court/getSubCourtList',
        method: 'GET',
        params: requestParams
      },
      success: (res) => {
        if (res.statusCode === 200) {
          resolve(res.data.data);
        } else {
          reject(new Error(`请求失败: ${res.statusCode}`));
        }
      },
      fail: (err) => {
        reject(new Error(`网络错误: ${err.errMsg}`));
      }
    });
  });
}

/**
 * 获取拓普网球(万胜围)场地预约设置
 * @param {Object} params - 查询参数 { startDate, endDate }
 * @returns {Promise} 请求Promise
 */
export function getTuoPuWanShengWeiVenueSettings(params = {}) {
  // 设置默认参数
  const today = new Date();
  const tomorrow = new Date(today.getTime() + 24 * 60 * 60 * 1000);
  
  const defaultParams = {
    timezoneOffset: -480,
    access_token: 'b358ec602831750f4e3bba8fa82e6f02',
    user_id: 9188847,
    box_id: 10243,
    language: 'zh_CN',
    api_version: 3,
    appId: 'wx3c3c93c6646e441e',
    startDate: today.toString(),
    endDate: tomorrow.toString(),
    id: 7565
  };
  
  // 合并参数
  const requestParams = { ...defaultParams, ...params };
  
  // 格式化日期参数（如果存在）
  if (requestParams.startDate) {
    if (requestParams.startDate instanceof Date) {
      requestParams.startDate = requestParams.startDate.toString();
    }
  }
  if (requestParams.endDate) {
    if (requestParams.endDate instanceof Date) {
      requestParams.endDate = requestParams.endDate.toString();
    }
  }
  
  // 生成API签名
  const api_signature = generateKuaiKeApiSignature(requestParams, defaultParams.appId);
  requestParams.api_signature = api_signature;
  
  return new Promise((resolve, reject) => {
    uni.request({
      url: 'https://fc-mp-0c81a8be-aa9a-4fae-8d6c-54b797768401.next.bspapp.com/cloudfunctions/proxyRequest',
      method: 'POST',
      header: {
        'content-type': 'application/json'
      },
      data: {
        url: 'https://api2.iwod.cn/court/getSubCourtList',
        method: 'GET',
        params: requestParams
      },
      success: (res) => {
        if (res.statusCode === 200) {
          resolve(res.data.data);
        } else {
          reject(new Error(`请求失败: ${res.statusCode}`));
        }
      },
      fail: (err) => {
        reject(new Error(`网络错误: ${err.errMsg}`));
      }
    });
  });
}

/**
 * 获取拓普网球(白云湖金铂天地)场地预约设置
 * @param {Object} params - 查询参数 { startDate, endDate }
 * @returns {Promise} 请求Promise
 */
export function getTuoPuBaiYunHuJinBoTianDiVenueSettings(params = {}) {
  // 设置默认参数
  const defaultParams = {
    timezoneOffset: -480,
    access_token: 'becaaf8d0f325178ff597d294043051a',
    user_id: '9188847',
    box_id: '19109',
    language: 'zh_CN',
    api_version: '3',
    appId: 'wx3c3c93c6646e441e',
    startDate: 'Wed Oct 15 2025 00:00:00 GMT+0800 (中国标准时间)',
    endDate: 'Thu Oct 16 2025 00:00:00 GMT+0800 (中国标准时间)',
    id: '10884'
  };
  
  // 合并参数
  const requestParams = { ...defaultParams, ...params };
  
  // 格式化日期参数（如果存在）
  if (requestParams.startDate) {
    if (requestParams.startDate instanceof Date) {
      requestParams.startDate = requestParams.startDate.toISOString().split('T')[0];
    }
  }
  if (requestParams.endDate) {
    if (requestParams.endDate instanceof Date) {
      requestParams.endDate = requestParams.endDate.toISOString().split('T')[0];
    }
  }
  
  // 生成API签名
  const api_signature = generateKuaiKeApiSignature(requestParams, requestParams.appId);
  requestParams.api_signature = api_signature;
  
  return new Promise((resolve, reject) => {
    uni.request({
      url: 'https://fc-mp-0c81a8be-aa9a-4fae-8d6c-54b797768401.next.bspapp.com/cloudfunctions/proxyRequest',
      method: 'POST',
      header: {
        'content-type': 'application/json'
      },
      data: {
        url: 'https://api2.iwod.cn/court/getSubCourtList',
        method: 'GET',
        params: requestParams
      },
      success: (res) => {
        if (res.statusCode === 200) {
          resolve(res.data.data);
        } else {
          reject(new Error(`请求失败: ${res.statusCode}`));
        }
      },
      fail: (err) => {
        reject(new Error(`网络错误: ${err.errMsg}`));
      }
    });
  });
}

/**
 * 获取拓普网球(南国花园)场地预约设置
 * @param {Object} params - 查询参数 { startDate, endDate }
 * @returns {Promise} 请求Promise
 */
export function getTuoPuNanGuoHuaYuanVenueSettings(params = {}) {
  // 设置默认参数
  const defaultParams = {
    timezoneOffset: -480,
    access_token: '509357fbebc7faa85608c3cfcb88c09f',
    user_id: 9188847,
    box_id: 8278,
    language: 'zh_CN',
    api_version: 3,
    appId: 'wx3c3c93c6646e441e',
    id: 2987
  };
  
  // 合并参数
  const requestParams = { ...defaultParams, ...params };
  
  // 格式化日期参数（如果存在）
  if (requestParams.startDate) {
    if (requestParams.startDate instanceof Date) {
      requestParams.startDate = requestParams.startDate.toString();
    }
  }
  if (requestParams.endDate) {
    if (requestParams.endDate instanceof Date) {
      requestParams.endDate = requestParams.endDate.toString();
    }
  }
  
  // 生成API签名
  requestParams.api_signature = generateKuaiKeApiSignature(requestParams, requestParams.appId);
  
  return new Promise((resolve, reject) => {
    uni.request({
      url: 'https://fc-mp-0c81a8be-aa9a-4fae-8d6c-54b797768401.next.bspapp.com/cloudfunctions/proxyRequest',
      method: 'POST',
      header: {
        'content-type': 'application/json'
      },
      data: {
        url: 'https://api2.iwod.cn/court/getSubCourtList',
        method: 'GET',
        params: requestParams
      },
      success: (res) => {
        if (res.statusCode === 200) {
          resolve(res.data.data);
        } else {
          reject(new Error(`请求失败: ${res.statusCode}`));
        }
      },
      fail: (err) => {
        reject(new Error(`网络错误: ${err.errMsg}`));
      }
    });
  });
}

/**
 * 获取拓普网球(新港东)场地预约设置
 * @param {Object} params - 查询参数 { startDate, endDate }
 * @returns {Promise} 请求Promise
 */
export function getTuoPuXinGangDongVenueSettings(params = {}) {
  // 设置默认参数
  const defaultParams = {
    timezoneOffset: -480,
    access_token: 'b358ec602831750f4e3bba8fa82e6f02',
    user_id: '9188847',
    box_id: '10391',
    language: 'zh_CN',
    api_version: '3',
    appId: 'wx3c3c93c6646e441e'
  };
  
  // 创建单个请求的函数
  const makeRequest = (id) => {
    // 合并参数（不包含api_signature）
    const requestParams = { ...defaultParams, ...params, id };
    
    // 格式化日期参数（如果存在）
    if (requestParams.startDate) {
      if (requestParams.startDate instanceof Date) {
        requestParams.startDate = requestParams.startDate.toString();
      }
    }
    if (requestParams.endDate) {
      if (requestParams.endDate instanceof Date) {
        requestParams.endDate = requestParams.endDate.toString();
      }
    }
    
    // 生成签名
    const api_signature = generateKuaiKeApiSignature(requestParams, defaultParams.appId);
    
    // 添加签名到参数中
    requestParams.api_signature = api_signature;
    
    return new Promise((resolve, reject) => {
      uni.request({
        url: 'https://fc-mp-0c81a8be-aa9a-4fae-8d6c-54b797768401.next.bspapp.com/cloudfunctions/proxyRequest',
        method: 'POST',
        header: {
          'content-type': 'application/json'
        },
        data: {
          url: 'https://api2.iwod.cn/court/getSubCourtList',
          method: 'GET',
          params: requestParams
        },
        success: (res) => {
          if (res.statusCode === 200) {
            resolve(res.data.data);
          } else {
            reject(new Error(`请求失败: ${res.statusCode}`));
          }
        }, 
        fail: (err) => {
          reject(new Error(`网络错误: ${err.errMsg}`));
        }
      });
    });
  };
  
  // 并发请求两个接口，分别使用id=4859和id=7733
  return Promise.all([
    makeRequest('4859'),
    makeRequest('7733')
  ]).then(results => {
    // 合并两个请求的结果
    const combinedData = {
      data: {
        code: 0,
        data: {
          courtList: []
        }
      }
    };
    
    // 合并courtList
    results.forEach(result => {
      if (result && result.data && result.data.data && result.data.data.courtList) {
        combinedData.data.data.courtList = combinedData.data.data.courtList.concat(result.data.data.courtList);
      }
    });
    
    return combinedData;
  });
}

/**
 * 获取丰泰花园网球场场地预约设置
 * @param {Object} params - 查询参数 { startDate, endDate }
 * @returns {Promise} 请求Promise
 */
export function getFengTaiHuaYuanVenueSettings(params = {}) {
  // 设置默认参数
  const defaultParams = {
    timezoneOffset: -480,
    access_token: 'f8e2a6e2ccd230a177d82056909def44',
    user_id: '9189184',
    box_id: '18648',
    language: 'zh_CN',
    api_version: '3',
    appId: 'wxc7f3f7975f41f64b',
    id: '10623'
  };
  
  // 合并参数
  const requestParams = { ...defaultParams, ...params };
  
  // 格式化日期参数（如果存在）
  if (requestParams.startDate) {
    if (requestParams.startDate instanceof Date) {
      requestParams.startDate = requestParams.startDate.toISOString().split('T')[0];
    }
  }
  if (requestParams.endDate) {
    if (requestParams.endDate instanceof Date) {
      requestParams.endDate = requestParams.endDate.toISOString().split('T')[0];
    }
  }
  
  // 生成API签名
  const api_signature = generateKuaiKeApiSignature(requestParams, defaultParams.appId);
  requestParams.api_signature = api_signature;
  
  return new Promise((resolve, reject) => {
    uni.request({
      url: 'https://fc-mp-0c81a8be-aa9a-4fae-8d6c-54b797768401.next.bspapp.com/cloudfunctions/proxyRequest',
      method: 'POST',
      header: {
        'content-type': 'application/json'
      },
      data: {
        url: 'https://api2.iwod.cn/court/getSubCourtList',
        method: 'GET',
        params: requestParams
      },
      success: (res) => {
        if (res.statusCode === 200) {
          resolve(res.data.data);
        } else {
          reject(new Error(`请求失败: ${res.statusCode}`));
        }
      },
      fail: (err) => {
        reject(new Error(`网络错误: ${err.errMsg}`));
      }
    });
  });
}

/**
 * 获取209网球中心场地预约设置
 * @param {Object} params - 查询参数 { startDate, endDate }
 * @returns {Promise} 请求Promise
 */
export function get209TennisVenueSettings(params = {}) {
  // 设置默认参数
  const defaultParams = {
    timezoneOffset: -480,
    access_token: '705bcfe9b125340ac4aefdff14900774',
    user_id: '9189184',
    box_id: '17535',
    language: 'zh_CN',
    api_version: '3',
    appId: 'wxc7f3f7975f41f64b'
  };
  
  // 创建单个请求的函数
  const makeRequest = (id) => {
    // 合并参数（不包含api_signature）
    const requestParams = { ...defaultParams, ...params, id };
    
    // 格式化日期参数（如果存在）
    if (requestParams.startDate) {
      if (requestParams.startDate instanceof Date) {
        requestParams.startDate = requestParams.startDate.toString();
      }
    }
    if (requestParams.endDate) {
      if (requestParams.endDate instanceof Date) {
        requestParams.endDate = requestParams.endDate.toString();
      }
    }
    
    // 生成签名
    const api_signature = generateKuaiKeApiSignature(requestParams, defaultParams.appId);
    
    // 添加签名到参数中
    requestParams.api_signature = api_signature;
    
    return new Promise((resolve, reject) => {
      uni.request({
        url: 'https://fc-mp-0c81a8be-aa9a-4fae-8d6c-54b797768401.next.bspapp.com/cloudfunctions/proxyRequest',
        method: 'POST',
        header: {
          'content-type': 'application/json'
        },
        data: {
          url: 'https://api2.iwod.cn/court/getSubCourtList',
          method: 'GET',
          params: requestParams
        },
        success: (res) => {
          if (res.statusCode === 200) {
            resolve(res.data.data);
          } else {
            reject(new Error(`请求失败: ${res.statusCode}`));
          }
        }, 
        fail: (err) => {
          reject(new Error(`网络错误: ${err.errMsg}`));
        }
      });
    });
  };
  
  // 并发请求两个接口，分别使用id=9807和id=9808
  return Promise.all([
    makeRequest('9807'),
    makeRequest('9808')
  ]).then(results => {
    // 合并两个请求的结果
    const combinedData = {
      data: {
        code: 0,
        data: {
          courtList: []
        }
      }
    };
    
    // 合并courtList
    results.forEach(result => {
      if (result && result.data && result.data.data && result.data.data.courtList) {
        combinedData.data.data.courtList = combinedData.data.data.courtList.concat(result.data.data.courtList);
      }
    });
    
    return combinedData;
  });
}

/**
 * 获取健潮网球场地预约设置
 * @param {Object} params - 查询参数 { startDate, endDate }
 * @returns {Promise} 请求Promise
 */
export function getJianChaoTennisVenueSettings(params = {}) {
  // 设置默认参数
  const defaultParams = {
    timezoneOffset: -480,
    access_token: '489bab99f3fb3b383aa430b7b09ca633',
    user_id: '9253790',
    box_id: '14256',
    language: 'zh_CN',
    api_version: '3',
    appId: 'wxb1554a6b6cc70e73'
  };
  
  // 创建单个请求的函数
  const makeRequest = (id) => {
    // 合并参数（不包含api_signature）
    const requestParams = { ...defaultParams, ...params, id };
    
    // 格式化日期参数（如果存在）
    if (requestParams.startDate) {
      if (requestParams.startDate instanceof Date) {
        requestParams.startDate = requestParams.startDate.toString();
      }
    }
    if (requestParams.endDate) {
      if (requestParams.endDate instanceof Date) {
        requestParams.endDate = requestParams.endDate.toString();
      }
    }
    
    // 生成签名
    const api_signature = generateKuaiKeApiSignature(requestParams, defaultParams.appId);
    
    // 添加签名到参数中
    requestParams.api_signature = api_signature;
    
    return new Promise((resolve, reject) => {
      uni.request({
        url: 'https://fc-mp-0c81a8be-aa9a-4fae-8d6c-54b797768401.next.bspapp.com/cloudfunctions/proxyRequest',
        method: 'POST',
        header: {
          'content-type': 'application/json'
        },
        data: {
          url: 'https://api2.iwod.cn/court/getSubCourtList',
          method: 'GET',
          params: requestParams
        },
        success: (res) => {
          if (res.statusCode === 200) {
            resolve(res.data.data);
          } else {
            reject(new Error(`请求失败: ${res.statusCode}`));
          }
        }, 
        fail: (err) => {
          reject(new Error(`网络错误: ${err.errMsg}`));
        }
      });
    });
  };
  
  // 并发请求两个接口，分别使用id=7672和id=7673
  return Promise.all([
    makeRequest('7672'),
    makeRequest('7673')
  ]).then(results => {
    // 合并两个请求的结果
    const combinedData = {
      data: {
        code: 0,
        data: {
          courtList: []
        }
      }
    };
    
    // 合并courtList
    results.forEach(result => {
      if (result && result.data && result.data.data && result.data.data.courtList) {
        combinedData.data.data.courtList = combinedData.data.data.courtList.concat(result.data.data.courtList);
      }
    });
    
    return combinedData;
  });
}

/**
 * 获取金满贯(旗峰山)场地预约设置
 * @param {Object} params - 查询参数 { startDate, endDate }
 * @returns {Promise} 请求Promise
 */
export function getJinManGuanQiFengShanVenueSettings(params = {}) {
  // 设置默认参数
  const defaultParams = {
    timezoneOffset: -480,
    access_token: '19a12e6f2b18eea7fa8919d874d2e4a0',
    user_id: '3657085',
    box_id: '9822',
    language: 'zh_CN',
    api_version: '3',
    appId: 'wx43d54f8c2495bdfa',
    id: '4379'
  };
  
  // 合并参数
  const requestParams = { ...defaultParams, ...params };
  
  // 格式化日期参数（如果存在）
  if (requestParams.startDate) {
    if (requestParams.startDate instanceof Date) {
      requestParams.startDate = requestParams.startDate.toISOString().split('T')[0];
    }
  }
  if (requestParams.endDate) {
    if (requestParams.endDate instanceof Date) {
      requestParams.endDate = requestParams.endDate.toISOString().split('T')[0];
    }
  }
  
  // 生成API签名
  const api_signature = generateKuaiKeApiSignature(requestParams, defaultParams.appId);
  requestParams.api_signature = api_signature;
  
  return new Promise((resolve, reject) => {
    uni.request({
      url: 'https://fc-mp-0c81a8be-aa9a-4fae-8d6c-54b797768401.next.bspapp.com/cloudfunctions/proxyRequest',
      method: 'POST',
      header: {
        'content-type': 'application/json'
      },
      data: {
        url: 'https://api2.iwod.cn/court/getSubCourtList',
        method: 'GET',
        params: requestParams
      },
      success: (res) => {
        if (res.statusCode === 200) {
          resolve(res.data.data);
        } else {
          reject(new Error(`请求失败: ${res.statusCode}`));
        }
      },
      fail: (err) => {
        reject(new Error(`网络错误: ${err.errMsg}`));
      }
    });
  });
}

/**
 * 获取花果山网球馆场地预约设置
 * @param {Object} params - 查询参数 { startDate, endDate }
 * @returns {Promise} 请求Promise
 */
export function getHuaGuoShanVenueSettings(params = {}) {
  // 设置默认参数
  const defaultParams = {
    timezoneOffset: -480,
    access_token: 'bbcb74a2814fd6bccb5e289f9629e363',
    user_id: 9189184,
    box_id: 15685,
    language: 'zh_CN',
    api_version: 3,
    appId: 'wxc7f3f7975f41f64b',
    id: 8702
  };
  
  // 合并参数
  const requestParams = { ...defaultParams, ...params };
  
  // 格式化日期参数（如果存在）
  if (requestParams.startDate) {
    if (requestParams.startDate instanceof Date) {
      requestParams.startDate = requestParams.startDate.toString();
    }
  }
  if (requestParams.endDate) {
    if (requestParams.endDate instanceof Date) {
      requestParams.endDate = requestParams.endDate.toString();
    }
  }
  
  // 生成API签名
  requestParams.api_signature = generateKuaiKeApiSignature(requestParams, requestParams.appId);
  
  return new Promise((resolve, reject) => {
    uni.request({
      url: 'https://fc-mp-0c81a8be-aa9a-4fae-8d6c-54b797768401.next.bspapp.com/cloudfunctions/proxyRequest',
      method: 'POST',
      header: {
        'content-type': 'application/json'
      },
      data: {
        url: 'https://api2.iwod.cn/court/getSubCourtList',
        method: 'GET',
        params: requestParams
      },
      success: (res) => {
        if (res.statusCode === 200) {
          resolve(res.data.data);
        } else {
          reject(new Error(`请求失败: ${res.statusCode}`));
        }
      },
      fail: (err) => {
        reject(new Error(`网络错误: ${err.errMsg}`));
      }
    });
  });
}

/**
 * 获取金满贯(华美学校)场地预约设置
 * @param {Object} params - 查询参数 { startDate, endDate }
 * @returns {Promise} 请求Promise
 */
export function getJinManGuanHuaMeiXueXiaoVenueSettings(params = {}) {
  // 设置默认参数
  const defaultParams = {
    timezoneOffset: -480,
    access_token: 'a717cd97a8b0efb93ce6b942edfbe4c4',
    user_id: 3657085,
    box_id: 16532,
    language: 'zh_CN',
    api_version: 3,
    appId: 'wx43d54f8c2495bdfa',
    id: 9205
  };
  
  // 合并参数
  const requestParams = { ...defaultParams, ...params };
  
  // 格式化日期参数（如果存在）
  if (requestParams.startDate) {
    if (requestParams.startDate instanceof Date) {
      requestParams.startDate = requestParams.startDate.toString();
    }
  }
  if (requestParams.endDate) {
    if (requestParams.endDate instanceof Date) {
      requestParams.endDate = requestParams.endDate.toString();
    }
  }
  
  // 生成API签名
  const api_signature = generateKuaiKeApiSignature(requestParams, defaultParams.appId);
  requestParams.api_signature = api_signature;
  
  return new Promise((resolve, reject) => {
    uni.request({
      url: 'https://fc-mp-0c81a8be-aa9a-4fae-8d6c-54b797768401.next.bspapp.com/cloudfunctions/proxyRequest',
      method: 'POST',
      header: {
        'content-type': 'application/json'
      },
      data: {
        url: 'https://api2.iwod.cn/court/getSubCourtList',
        method: 'GET',
        params: requestParams
      },
      success: (res) => {
        if (res.statusCode === 200) {
          resolve(res.data.data);
        } else {
          reject(new Error(`请求失败: ${res.statusCode}`));
        }
      },
      fail: (err) => {
        reject(new Error(`网络错误: ${err.errMsg}`));
      }
    });
  });
}

/**
 * 获取金满贯(白云)场地预约设置
 * @param {Object} params - 查询参数 { startDate, endDate }
 * @returns {Promise} 请求Promise
 */
export function getJinManGuanBaiYunVenueSettings(params = {}) {
  // 设置默认参数
  const defaultParams = {
    timezoneOffset: -480,
    access_token: '8b4d08f66d92c02b190e89d60bb9e8d7',
    user_id: '3657085',
    box_id: '10294',
    language: 'zh_CN',
    api_version: '3',
    appId: 'wx43d54f8c2495bdfa',
    id: '4810'
  };
  
  // 合并参数
  const requestParams = { ...defaultParams, ...params };
  
  // 格式化日期参数（如果存在）
  if (requestParams.startDate) {
    if (requestParams.startDate instanceof Date) {
      requestParams.startDate = requestParams.startDate.toISOString().split('T')[0];
    }
  }
  
  if (requestParams.endDate) {
    if (requestParams.endDate instanceof Date) {
      requestParams.endDate = requestParams.endDate.toISOString().split('T')[0];
    }
  }
  
  // 生成API签名
  requestParams.api_signature = generateKuaiKeApiSignature(requestParams, requestParams.appId);
  
  return new Promise((resolve, reject) => {
    uni.request({
      url: 'https://fc-mp-0c81a8be-aa9a-4fae-8d6c-54b797768401.next.bspapp.com/cloudfunctions/proxyRequest',
      method: 'POST',
      header: {
        'content-type': 'application/json'
      },
      data: {
        url: 'https://api2.iwod.cn/court/getSubCourtList',
        method: 'GET',
        params: requestParams
      },
      success: (res) => {
        if (res.statusCode === 200) {
          resolve(res.data.data);
        } else {
          reject(new Error(`请求失败: ${res.statusCode}`));
        }
      },
      fail: (err) => {
        reject(new Error(`网络错误: ${err.errMsg}`));
      }
    });
  });
}

/**
 * 获取金满贯(珠江新城)场地预约设置
 * @param {Object} params - 查询参数
 * @returns {Promise} 请求Promise
 */
export function getJinManGuanZhuJiangXinChengVenueSettings(params = {}) {
  // 设置默认参数
  const defaultParams = {
    timezoneOffset: -480,
    access_token: 'b4f21bc0a0b065620b3b9c4a5f6371f8',
    user_id: '3657085',
    box_id: '11871',
    language: 'zh_CN',
    api_version: '3',
    appId: 'wx43d54f8c2495bdfa'
  };
  
  // 创建单个请求的函数
  const makeRequest = (id) => {
    // 合并参数（不包含api_signature）
    const requestParams = { ...defaultParams, ...params, id };
    
    // 格式化日期参数（如果存在）
    if (requestParams.startDate) {
      if (requestParams.startDate instanceof Date) {
        requestParams.startDate = requestParams.startDate.toISOString().split('T')[0];
      }
    }
    if (requestParams.endDate) {
      if (requestParams.endDate instanceof Date) {
        requestParams.endDate = requestParams.endDate.toISOString().split('T')[0];
      }
    }
    
    // 生成签名
    const api_signature = generateKuaiKeApiSignature(requestParams, defaultParams.appId);
    
    // 添加签名到参数中
    requestParams.api_signature = api_signature;
    
    return new Promise((resolve, reject) => {
      uni.request({
        url: 'https://fc-mp-0c81a8be-aa9a-4fae-8d6c-54b797768401.next.bspapp.com/cloudfunctions/proxyRequest',
        method: 'POST',
        header: {
          'content-type': 'application/json'
        },
        data: {
          url: 'https://api2.iwod.cn/court/getSubCourtList',
          method: 'GET',
          params: requestParams
        },
        success: (res) => {
          if (res.statusCode === 200) {
            resolve(res.data.data);
          } else {
            reject(new Error(`请求失败: ${res.statusCode}`));
          }
        }, 
        fail: (err) => {
          reject(new Error(`网络错误: ${err.errMsg}`));
        }
      });
    });
  };
  
  // 并行请求两个id的数据
  return Promise.all([
    makeRequest('6299'),
    makeRequest('9749')
  ]).then(results => {
    // 合并两个请求的结果
    const combinedData = {
      data: {
        data: {
          courtList: []
        }
      }
    };
    
    // 合并courtList数据
    results.forEach(result => {
      if (result && result.data && result.data.data && result.data.data.courtList) {
        combinedData.data.data.courtList = combinedData.data.data.courtList.concat(result.data.data.courtList);
      }
    });
    
    return combinedData;
  });
}

/**
 * 获取金满贯(华美麓湖)场地预约设置
 * @param {Object} params - 查询参数
 * @returns {Promise} 请求Promise
 */
export function getJinManGuanHuaMeiLuHuVenueSettings(params = {}) {
  // 设置默认参数
  const defaultParams = {
    timezoneOffset: -480,
    access_token: 'c210f3467891cc41bd25fa923446fc84',
    user_id: '3657085',
    box_id: '15544',
    language: 'zh_CN',
    api_version: '3',
    appId: 'wx43d54f8c2495bdfa'
  };
  
  // 合并参数
  const requestParams = { ...defaultParams, ...params };
  
  // 格式化日期参数（如果存在）
  if (requestParams.startDate) {
    if (requestParams.startDate instanceof Date) {
      requestParams.startDate = requestParams.startDate.toISOString().split('T')[0];
    }
  }
  if (requestParams.endDate) {
    if (requestParams.endDate instanceof Date) {
      requestParams.endDate = requestParams.endDate.toISOString().split('T')[0];
    }
  }
  
  // 创建请求的函数
  const makeRequest = (id) => {
    const requestParamsWithId = { ...requestParams, id };
    
    // 生成API签名
    const api_signature = generateKuaiKeApiSignature(requestParamsWithId, defaultParams.appId);
    requestParamsWithId.api_signature = api_signature;
    
    return new Promise((resolve, reject) => {
      uni.request({
        url: 'https://fc-mp-0c81a8be-aa9a-4fae-8d6c-54b797768401.next.bspapp.com/cloudfunctions/proxyRequest',
        method: 'POST',
        header: {
          'content-type': 'application/json'
        },
        data: {
          url: 'https://api2.iwod.cn/court/getSubCourtList',
          method: 'GET',
          params: requestParamsWithId
        },
        success: (res) => {
          if (res.statusCode === 200) {
            resolve(res.data.data);
          } else {
            reject(new Error(`请求失败: ${res.statusCode}`));
          }
        },
        fail: (err) => {
          reject(new Error(`网络错误: ${err.errMsg}`));
        }
      });
    });
  };
  
  // 并行请求两个id的数据
  return Promise.all([
    makeRequest('8571'),
    makeRequest('10920')
  ]).then(results => {
    // 合并两个请求的结果
    const combinedData = {
      data: {
        data: {
          courtList: []
        }
      }
    };
    
    // 合并courtList数据
    results.forEach(result => {
      if (result && result.data && result.data.data && result.data.data.courtList) {
        combinedData.data.data.courtList = combinedData.data.data.courtList.concat(result.data.data.courtList);
      }
    });
    console.log('combinedData',combinedData);
    
    return combinedData;
  });
}

/**
 * 获取金满贯(琶洲保利世贸)场地预约设置
 * @param {Object} params - 查询参数 { startDate, endDate }
 * @returns {Promise} 请求Promise
 */
export function getJinManGuanPaZhouVenueSettings(params = {}) {
  // 设置默认参数
  const defaultParams = {
    timezoneOffset: -480,
    access_token: 'e365a6d077a6b8b45e955800055df928',
    user_id: '3657085',
    box_id: '13569',
    language: 'zh_CN',
    api_version: '3',
    appId: 'wx43d54f8c2495bdfa'
  };
  
  // 合并参数
  const requestParams = { ...defaultParams, ...params };
  
  // 格式化日期参数（如果存在）
  if (requestParams.startDate) {
    if (requestParams.startDate instanceof Date) {
      requestParams.startDate = requestParams.startDate.toISOString().split('T')[0];
    }
  }
  if (requestParams.endDate) {
    if (requestParams.endDate instanceof Date) {
      requestParams.endDate = requestParams.endDate.toISOString().split('T')[0];
    }
  }
  
  // 创建两个请求的函数
  const makeRequest = (id) => {
    const requestParamsWithId = { ...requestParams, id };
    
    // 生成API签名
    const api_signature = generateKuaiKeApiSignature(requestParamsWithId, defaultParams.appId);
    requestParamsWithId.api_signature = api_signature;
    
    return new Promise((resolve, reject) => {
      uni.request({
        url: 'https://fc-mp-0c81a8be-aa9a-4fae-8d6c-54b797768401.next.bspapp.com/cloudfunctions/proxyRequest',
        method: 'POST',
        header: {
          'content-type': 'application/json'
        },
        data: {
          url: 'https://api2.iwod.cn/court/getSubCourtList',
          method: 'GET',
          params: requestParamsWithId
        },
        success: (res) => {
          if (res.statusCode === 200) {
            resolve(res.data.data);
          } else {
            reject(new Error(`请求失败: ${res.statusCode}`));
          }
        },
        fail: (err) => {
          reject(new Error(`网络错误: ${err.errMsg}`));
        }
      });
    });
  };
  
  // 并行请求两个id的数据
  return Promise.all([
    makeRequest('7306'),
    makeRequest('7674')
  ]).then(results => {
    // 合并两个请求的结果
    const combinedData = {
      data: {
        data: {
          courtList: []
        }
      }
    };
    
    // 合并courtList数据
    results.forEach(result => {
      if (result && result.data && result.data.data && result.data.data.courtList) {
        combinedData.data.data.courtList = combinedData.data.data.courtList.concat(result.data.data.courtList);
      }
    });
    
    return combinedData;
  });
}

/**
 * 获取金满贯(华工北)场地预约设置
 * @param {Object} params - 查询参数 { startDate, endDate }
 * @returns {Promise} 请求Promise
 */
export function getJinManGuanHuaGongBeiVenueSettings(params = {}) {
  // 设置默认参数
  const defaultParams = {
    timezoneOffset: -480,
    access_token: '096b3c77c26d20a1cfb5273318ea16df',
    user_id: '3657085',
    box_id: '7112',
    language: 'zh_CN',
    api_version: '3',
    appId: 'wx43d54f8c2495bdfa',
    id: '1970'
  };
  
  console.log("getJinManGuanHuaGongBeiVenueSettings params", params);
  
  // 合并参数（不包含api_signature）
  const requestParams = { ...defaultParams, ...params };
  
  // 格式化日期参数（如果存在）
  if (requestParams.startDate) {
    if (requestParams.startDate instanceof Date) {
      requestParams.startDate = requestParams.startDate.toISOString().split('T')[0];
    }
  }
  if (requestParams.endDate) {
    if (requestParams.endDate instanceof Date) {
      requestParams.endDate = requestParams.endDate.toISOString().split('T')[0];
    }
  }
  
  // 生成签名
  const api_signature = generateKuaiKeApiSignature(requestParams, defaultParams.appId);
  
  // 添加签名到参数中
  requestParams.api_signature = api_signature;
  
  return new Promise((resolve, reject) => {
    uni.request({
      url: 'https://fc-mp-0c81a8be-aa9a-4fae-8d6c-54b797768401.next.bspapp.com/cloudfunctions/proxyRequest',
      method: 'POST',
      header: {
        'content-type': 'application/json'
      },
      data: {
        url: 'https://api2.iwod.cn/court/getSubCourtList',
        method: 'GET',
        params: requestParams
      },
      success: (res) => {
        if (res.statusCode === 200) {
          resolve(res.data.data);
        } else {
          reject(new Error(`请求失败: ${res.statusCode}`));
        }
      },
      fail: (err) => {
        reject(new Error(`网络错误: ${err.errMsg}`));
      }
    });
  });
}

export function getJinManGuanWeiSiTingVenueSettings(params = {}) {
  // 设置默认参数
  const defaultParams = {
    timezoneOffset: -480,
    access_token: '66e81c9870756d99881505d56c73336a',
    user_id: '3657085',
    box_id: '7822',
    language: 'zh_CN',
    api_version: '3',
    appId: 'wx43d54f8c2495bdfa',
    id: '2658'
  };
  
  // 合并参数（不包含api_signature）
  const requestParams = { ...defaultParams, ...params };
  
  // 格式化日期参数（如果存在）
  if (requestParams.startDate) {
    if (requestParams.startDate instanceof Date) {
      requestParams.startDate = requestParams.startDate.toISOString().split('T')[0];
    }
  }
  if (requestParams.endDate) {
    if (requestParams.endDate instanceof Date) {
      requestParams.endDate = requestParams.endDate.toISOString().split('T')[0];
    }
  }
  
  // 生成签名
  const api_signature = generateKuaiKeApiSignature(requestParams, defaultParams.appId);
  
  // 添加签名到参数中
  requestParams.api_signature = api_signature;
  
  return new Promise((resolve, reject) => {
    uni.request({
      url: 'https://fc-mp-0c81a8be-aa9a-4fae-8d6c-54b797768401.next.bspapp.com/cloudfunctions/proxyRequest',
      method: 'POST',
      header: {
        'content-type': 'application/json'
      },
      data: {
        url: 'https://api2.iwod.cn/court/getSubCourtList',
        method: 'GET',
        params: requestParams
      },
      success: (res) => {
        if (res.statusCode === 200) {
          resolve(res.data.data);
        } else {
          reject(new Error(`请求失败: ${res.statusCode}`));
        }
      }, 
      fail: (err) => {
        reject(new Error(`网络错误: ${err.errMsg}`));
      }
    });
  });
}

export function getJinManGuanTianHeChengVenueSettings(params = {}) {
  // 设置默认参数
  const defaultParams = {
    timezoneOffset: -480,
    access_token: 'c3df46431cbdd13fc3bc8692ff3996a7',
    user_id: 3657085,
    box_id: 7115,
    language: 'zh_CN',
    api_version: 3,
    appId: 'wx43d54f8c2495bdfa'
  };
  
  // 合并参数
  const requestParams = { ...defaultParams, ...params };
  
  // 格式化日期参数（如果存在）
  if (requestParams.startDate) {
    if (requestParams.startDate instanceof Date) {
      requestParams.startDate = requestParams.startDate.toISOString().split('T')[0];
    }
  }
  if (requestParams.endDate) {
    if (requestParams.endDate instanceof Date) {
      requestParams.endDate = requestParams.endDate.toISOString().split('T')[0];
    }
  }
  
  // 创建两个请求，分别使用id=1980和id=1981
  const createRequest = (id) => {
    const paramsWithId = { ...requestParams, id };
    
    // 生成API签名
    const api_signature = generateKuaiKeApiSignature(paramsWithId, paramsWithId.appId);
    paramsWithId.api_signature = api_signature;
    
    return new Promise((resolve, reject) => {
      uni.request({
        url: 'https://fc-mp-0c81a8be-aa9a-4fae-8d6c-54b797768401.next.bspapp.com/cloudfunctions/proxyRequest',
        method: 'POST',
        header: {
          'content-type': 'application/json'
        },
        data: {
          url: 'https://api2.iwod.cn/court/getSubCourtList',
          method: 'GET',
          params: paramsWithId
        },
        success: (res) => {
          if (res.statusCode === 200) {
            resolve(res.data.data);
          } else {
            reject(new Error(`请求失败: ${res.statusCode}`));
          }
        },
        fail: (err) => {
          reject(new Error(`网络错误: ${err.errMsg}`));
        }
      });
    });
  };
  
  // 并行执行两个请求
  return Promise.all([
    createRequest(1980),
    createRequest(1981)
  ]).then(results => {
    // 合并两个请求的结果
    const [result1, result2] = results;
    
    // 如果两个结果都有效，合并courtList
    if (result1 && result1.data && result1.data.data && result1.data.data.courtList &&
        result2 && result2.data && result2.data && result2.data.data.courtList) {
      
      // 为ID为1981的数据添加subClassroomName
      const processedResult2CourtList = result2.data.data.courtList.map(court => ({
        ...court,
        subClassroomName: '1号儿童场'
      }));
      
      const mergedResult = {
        ...result1,
        data: {
          ...result1.data,
          data: {
            ...result1.data.data,
            courtList: [
              ...result1.data.data.courtList,
              ...processedResult2CourtList
            ]
          }
        }
      };
      console.log("mergedResult",mergedResult);
      
      return mergedResult;
    }
    
    // 如果只有一个结果有效，返回有效的那个
    if (result1 && result1.data && result1.data.data && result1.data.data.courtList) {
      return result1;
    }
    
    if (result2 && result2.data && result2.data.data && result2.data.data.courtList) {
      return result2;
    }
    
    // 如果都无效，返回第一个结果
    return result1;
  });
}

export function getJinManGuanHuaGongDaXueChengVenueSettings(params = {}) {
  // 设置默认参数
  const defaultParams = {
    timezoneOffset: -480,
    access_token: '63adbf8dfb4b5b9f6fa0574038043958',
    user_id: 3657085,
    box_id: 7821,
    language: 'zh_CN',
    api_version: 3,
    appId: 'wx43d54f8c2495bdfa'
  };
  
  // 合并参数
  const requestParams = { ...defaultParams, ...params };
  
  // 格式化日期参数（如果存在）
  if (requestParams.startDate) {
    if (requestParams.startDate instanceof Date) {
      requestParams.startDate = requestParams.startDate.toISOString().split('T')[0];
    }
  }
  if (requestParams.endDate) {
    if (requestParams.endDate instanceof Date) {
      requestParams.endDate = requestParams.endDate.toISOString().split('T')[0];
    }
  }
  
  // 创建两个请求，分别使用id=3129和id=3130
  const createRequest = (id) => {
    const paramsWithId = { ...requestParams, id };
    
    // 生成API签名
    const api_signature = generateKuaiKeApiSignature(paramsWithId, paramsWithId.appId);
    paramsWithId.api_signature = api_signature;
    
    return new Promise((resolve, reject) => {
      uni.request({
        url: 'https://fc-mp-0c81a8be-aa9a-4fae-8d6c-54b797768401.next.bspapp.com/cloudfunctions/proxyRequest',
        method: 'POST',
        header: {
          'content-type': 'application/json'
        },
        data: {
          url: 'https://api2.iwod.cn/court/getSubCourtList',
          method: 'GET',
          params: paramsWithId
        },
        success: (res) => {
          if (res.statusCode === 200) {
            resolve(res.data.data);
          } else {
            reject(new Error(`请求失败: ${res.statusCode}`));
          }
        },
        fail: (err) => {
          reject(new Error(`网络错误: ${err.errMsg}`));
        }
      });
    });
  };
  
  // 并行执行两个请求
  return Promise.all([
    createRequest(3129),
    createRequest(3130)
  ]).then(results => {
    // 合并两个请求的结果
    const [result1, result2] = results;
    
    // 如果两个结果都有效，合并courtList
    if (result1 && result1.data && result1.data.data && result1.data.data.courtList &&
        result2 && result2.data && result2.data && result2.data.data.courtList) {
      
      const mergedResult = {
        ...result1,
        data: {
          ...result1.data,
          data: {
            ...result1.data.data,
            courtList: [
              ...result1.data.data.courtList.map(item => ({
                ...item,
                subClassroomName: item.subClassroomName + result1.data.data.courtName
              })),
              ...result2.data.data.courtList.map(item => ({
                ...item,
                subClassroomName: item.subClassroomName + result2.data.data.courtName
              }))
            ]
          }
        }
      };
      console.log("mergedResult",mergedResult);
      
      return mergedResult;
    }
    
    // 如果只有一个结果有效，返回有效的那个
    if (result1 && result1.data && result1.data.data && result1.data.data.courtList) {
      return result1;
    }
    
    if (result2 && result2.data && result2.data.data && result2.data.data.courtList) {
      return result2;
    }
    
    // 如果都无效，返回第一个结果
    return result1;
  });
}

export function getJinManGuanPanJiangHuaYuanVenueSettings(params = {}) {
  // 设置默认参数
  const today = new Date();
  const tomorrow = new Date(today.getTime() + 24 * 60 * 60 * 1000);
  
  const defaultParams = {
    timezoneOffset: -480,
    access_token: '61cef8b3b59679f29fe16df0f030a583',
    user_id: 3657085,
    box_id: 7114,
    language: 'zh_CN',
    api_version: 3,
    appId: 'wx43d54f8c2495bdfa',
    startDate: today,
    endDate: tomorrow,
    id: 1982
  };
  
  // 合并参数
  const requestParams = { ...defaultParams, ...params };
  
  // 格式化日期参数（如果存在）
  if (requestParams.startDate) {
    if (requestParams.startDate instanceof Date) {
      requestParams.startDate = requestParams.startDate.toISOString().split('T')[0];
    }
  }
  if (requestParams.endDate) {
    if (requestParams.endDate instanceof Date) {
      requestParams.endDate = requestParams.endDate.toISOString().split('T')[0];
    }
  }
  
  // 生成API签名
  const api_signature = generateKuaiKeApiSignature(requestParams, requestParams.appId);
  requestParams.api_signature = api_signature;
  
  return new Promise((resolve, reject) => {
    uni.request({
      url: 'https://fc-mp-0c81a8be-aa9a-4fae-8d6c-54b797768401.next.bspapp.com/cloudfunctions/proxyRequest',
      method: 'POST',
      header: {
        'content-type': 'application/json'
      },
      data: {
        url: 'https://api2.iwod.cn/court/getSubCourtList',
        method: 'GET',
        params: requestParams
      },
      success: (res) => {
        if (res.statusCode === 200) {
          resolve(res.data.data);
        } else {
          reject(new Error(`请求失败: ${res.statusCode}`));
        }
      },
      fail: (err) => {
        reject(new Error(`网络错误: ${err.errMsg}`));
      }
    });
  });
}

/**
 * 获取金满贯(华工西)场地预约设置
 * @param {Object} params - 查询参数 { startDate, endDate }
 * @returns {Promise} 请求Promise
 */
export function getJinManGuanHuaGongXiVenueSettings(params = {}) {
  // 设置默认参数
  const defaultParams = {
    timezoneOffset: -480,
    access_token: 'a31a6358693d2ce11dd32b66fe7c3486',
    user_id: '3657085',
    box_id: '7112',
    language: 'zh_CN',
    api_version: '3',
    appId: 'wx43d54f8c2495bdfa',
    id: '1970'
  };
  
  // 合并参数
  const requestParams = { ...defaultParams, ...params };
  
  // 格式化日期参数（如果存在）
  if (requestParams.startDate) {
    if (requestParams.startDate instanceof Date) {
      requestParams.startDate = requestParams.startDate.toISOString().split('T')[0];
    }
  }
  if (requestParams.endDate) {
    if (requestParams.endDate instanceof Date) {
      requestParams.endDate = requestParams.endDate.toISOString().split('T')[0];
    }
  }
  
  // 生成API签名
  const apiSignature = generateKuaiKeApiSignature(requestParams, requestParams.appId);
  requestParams.api_signature = apiSignature;
  
  return new Promise((resolve, reject) => {
    uni.request({
      url: 'https://fc-mp-0c81a8be-aa9a-4fae-8d6c-54b797768401.next.bspapp.com/cloudfunctions/proxyRequest',
      method: 'POST',
      header: {
        'content-type': 'application/json'
      },
      data: {
        url: 'https://api2.iwod.cn/court/getSubCourtList',
        method: 'GET',
        params: requestParams
      },
      success: (res) => {
        if (res.statusCode === 200) {
          resolve(res.data.data);
        } else {
          reject(new Error(`请求失败: ${res.statusCode}`));
        }
      },
      fail: (err) => {
        reject(new Error(`网络错误: ${err.errMsg}`));
      }
    });
  });
}

/**
 * 获取金满贯(海珠香格里拉)场地预约设置
 * @param {Object} params - 查询参数 { startDate, endDate }
 * @returns {Promise} 请求Promise
 */
export function getJinManGuanHaiZhuVenueSettings(params = {}) {
  // 设置默认参数
  const defaultParams = {
    timezoneOffset: -480,
    access_token: 'e99f62b73e2ae61ac9fe4025f86dace0',
    user_id: '3657085',
    box_id: '7111',
    language: 'zh_CN',
    api_version: '3',
    appId: 'wx43d54f8c2495bdfa',
    id: '1976'
  };
  
  // 合并参数
  const requestParams = { ...defaultParams, ...params };
  
  // 格式化日期参数（如果存在）
  if (requestParams.startDate) {
    if (requestParams.startDate instanceof Date) {
      requestParams.startDate = requestParams.startDate.toISOString().split('T')[0];
    }
  }
  if (requestParams.endDate) {
    if (requestParams.endDate instanceof Date) {
      requestParams.endDate = requestParams.endDate.toISOString().split('T')[0];
    }
  }
  
  // 生成API签名
  const api_signature = generateKuaiKeApiSignature(requestParams, defaultParams.appId);
  requestParams.api_signature = api_signature;
  
  return new Promise((resolve, reject) => {
    uni.request({
      url: 'https://fc-mp-0c81a8be-aa9a-4fae-8d6c-54b797768401.next.bspapp.com/cloudfunctions/proxyRequest',
      method: 'POST',
      header: {
        'content-type': 'application/json'
      },
      data: {
        url: 'https://api2.iwod.cn/court/getSubCourtList',
        method: 'GET',
        params: requestParams
      },
      success: (res) => {
        if (res.statusCode === 200) {
          resolve(res.data.data);
        } else {
          reject(new Error(`请求失败: ${res.statusCode}`));
        }
      },
      fail: (err) => {
        reject(new Error(`网络错误: ${err.errMsg}`));
      }
    });
  });
}

/**
 * 获取金满贯(皇冠假日)场地预约设置
 * @param {Object} params - 查询参数 { startDate, endDate }
 * @returns {Promise} 请求Promise
 */
export function getJinManGuanHuangGuanVenueSettings(params = {}) {
  // 设置默认参数
  const defaultParams = {
    timezoneOffset: -480,
    access_token: 'bd506239ec14fd312684c18d4046ed95',
    user_id: '3657085',
    box_id: '7110',
    language: 'zh_CN',
    api_version: '3',
    appId: 'wx43d54f8c2495bdfa'
  };
  
  // 创建单个请求的函数
  const makeRequest = (id) => {
    // 合并参数（不包含api_signature）
    const requestParams = { ...defaultParams, ...params, id };
    
    // 格式化日期参数（如果存在）
    if (requestParams.startDate) {
      if (requestParams.startDate instanceof Date) {
        requestParams.startDate = requestParams.startDate.toISOString().split('T')[0];
      }
    }
    if (requestParams.endDate) {
      if (requestParams.endDate instanceof Date) {
        requestParams.endDate = requestParams.endDate.toISOString().split('T')[0];
      }
    }
    
    // 生成签名
    const api_signature = generateKuaiKeApiSignature(requestParams, defaultParams.appId);
    
    // 添加签名到参数中
    requestParams.api_signature = api_signature;
    
    return new Promise((resolve, reject) => {
      uni.request({
        url: 'https://fc-mp-0c81a8be-aa9a-4fae-8d6c-54b797768401.next.bspapp.com/cloudfunctions/proxyRequest',
        method: 'POST',
        header: {
          'content-type': 'application/json'
        },
        data: {
          url: 'https://api2.iwod.cn/court/getSubCourtList',
          method: 'GET',
          params: requestParams
        },
        success: (res) => {
          if (res.statusCode === 200) {
            resolve(res.data.data);
          } else {
            reject(new Error(`请求失败: ${res.statusCode}`));
          }
        },
        fail: (err) => {
          reject(new Error(`网络错误: ${err.errMsg}`));
        }
      });
    });
  };
  
  // 同时请求两组参数
  return Promise.all([
    makeRequest('2417'),  // 第一组参数
    makeRequest('2418')   // 第二组参数
  ]).then(([result1, result2]) => {
    // 合并两个结果的 courtList
    const mergedResult = {
      ...result1,
      data: {
        ...result1.data,
        data: {
          ...result1.data.data,
          courtList: [
            ...(result1.data.data.courtList || []),
            ...(result2.data.data.courtList || [])
          ]
        }
      }
    };
    
    return mergedResult;
  });
}

/**
 * 获取晟旋网球(大壮国际店)场地预约设置
 * @param {Object} params - 查询参数 { date }
 * @returns {Promise} 请求Promise
 */
export function getShengXuanDaZhuangVenueSettings(params = {}) {
  // 设置默认参数
  const defaultParams = {
    stadium_id: 14383948801,
    business_id: 12669117442,
    scene_id: 19755603857408,
    date: "2025-10-11"
  };
  
  // 合并参数
  const requestParams = { ...defaultParams, ...params };
  
  return new Promise((resolve, reject) => {
    uni.request({
      url: 'https://fc-mp-0c81a8be-aa9a-4fae-8d6c-54b797768401.next.bspapp.com/cloudfunctions/proxyRequest',
      method: 'POST',
      header: {
        'content-type': 'application/json'
      },
      data: {
        url: 'https://api.d2yun.cn/v2/member/space_resource/list',
        method: 'GET',
        params: requestParams
      },
      success: (res) => {
        if (res.statusCode === 200) {
          resolve(res.data.data);
        } else {
          reject(new Error(`请求失败: ${res.statusCode}`));
        }
      }, 
      fail: (err) => {
        reject(new Error(`网络错误: ${err.errMsg}`));
      }
    });
  });
}

/**
 * GET请求
 * @param {string} url - 请求地址
 * @param {Object} data - 请求参数
 * @param {Object} options - 其他配置
 * @returns {Promise} 请求Promise
 */
export function get(url, data = {}, options = {}) {
  return request({
    url,
    method: 'GET',
    data,
    ...options
  });
}

/**
 * POST请求
 * @param {string} url - 请求地址
 * @param {Object} data - 请求参数
 * @param {Object} options - 其他配置
 * @returns {Promise} 请求Promise
 */
export function post(url, data = {}, options = {}) {
  return request({
    url,
    method: 'POST',
    data,
    ...options
  });
}

/**
 * PUT请求
 * @param {string} url - 请求地址
 * @param {Object} data - 请求参数
 * @param {Object} options - 其他配置
 * @returns {Promise} 请求Promise
 */
export function put(url, data = {}, options = {}) {
  return request({
    url,
    method: 'PUT',
    data,
    ...options
  });
}

/**
 * DELETE请求
 * @param {string} url - 请求地址
 * @param {Object} data - 请求参数
 * @param {Object} options - 其他配置
 * @returns {Promise} 请求Promise
 */
export function del(url, data = {}, options = {}) {
  return request({
    url,
    method: 'DELETE',
    data,
    ...options
  });
}

/**
 * 获取场地列表
 * @param {Object} params - 查询参数
 * @returns {Promise} 请求Promise
 */
export function getVenueList(params = {}) {
  return get('/venues', params);
}

/**
 * 获取场地详情
 * @param {number} id - 场地ID
 * @returns {Promise} 请求Promise
 */
export function getVenueDetail(id) {
  return get(`/venues/${id}`);
}

/**
 * 获取库卡场地预约设置
 * @param {Object} params - 查询参数 { userId, projectUid, dateTime }
 * @returns {Promise} 请求Promise
 */
export function getZhuoLeVenueSettings(params = {}) {
  // 设置默认参数
  const defaultParams = {
    userId: 5710920,
    projectUid: "0",
    dateTime: "2025-08-13"
  };
  
  // 合并参数
  const requestParams = { ...defaultParams, ...params };
  
  return new Promise((resolve, reject) => {
    uni.request({
      url: 'https://fc-mp-0c81a8be-aa9a-4fae-8d6c-54b797768401.next.bspapp.com/cloudfunctions/proxyRequest',
      method: 'POST',
      header: {
        'content-type': 'application/json'
      },
      data: {
        url: 'https://wxservice-stg48.pospal.cn/wxapi/AppointmentVenue/LoadValidClassRoomApptSettingV2',
        method: 'POST',
        data: requestParams,
        headers: {
          'PSPLVISITORAUTO': 'API',
          'APPTYPE': '1',
          'VERSIONINFO': 'NC|2025.02.28',
          'STOREID': '5710920'
        }
      },
      success: (res) => {
        if (res.statusCode === 200) {
          resolve(res.data.data);
        } else {
          reject(new Error(`请求失败: ${res.statusCode}`));
        }
      }, 
      fail: (err) => {
        reject(new Error(`网络错误: ${err.errMsg}`));
      }
    });
  });
}

/**
 * 获取向阳彩鸿湾场地预约设置
 * @param {Object} params - 查询参数 { basicId, merchantId, userId, reserveDate }
 * @returns {Promise} 请求Promise
 */
export function getXiangYangVenueSettings(params = {}) {
  // 设置默认参数
  const defaultParams = {
    basicId: "403170525",
    merchantId: "10166",
    userId: "",
    reserveDate: "2025-08-14"
  };
  
  // 合并参数
  const requestParams = { ...defaultParams, ...params };
  
  return new Promise((resolve, reject) => {
    uni.request({
      url: 'https://fc-mp-0c81a8be-aa9a-4fae-8d6c-54b797768401.next.bspapp.com/cloudfunctions/proxyRequest',
      method: 'POST',
      header: {
        'content-type': 'application/json'
      },
      data: {
        url: 'https://api.saas.changxiaoer.cn/consumer/price/front',
        method: 'POST',
        data: requestParams,
        headers: {
          'content-type': 'application/json',
          'cxe-security-code': 'a45ef582fccf43db9b5c4254c2e33600'
        }
      },
      success: (res) => {
        if (res.statusCode === 200) {
          resolve(res.data.data);
        } else {
          reject(new Error(`请求失败: ${res.statusCode}`));
        }
      }, 
      fail: (err) => {
        reject(new Error(`网络错误: ${err.errMsg}`));
      }
    });
  });
}

/**
 * 获取向阳康帝校区场地预约设置
 * @param {Object} params - 查询参数 { basicId, merchantId, userId, reserveDate }
 * @returns {Promise} 请求Promise
 */
export function getXiangYangKangDiVenueSettings(params = {}) {
  // 设置默认参数
  const defaultParams = {
    basicId: "403144937",
    merchantId: "10166",
    userId: "",
    reserveDate: "2025-08-13"
  };
  
  // 合并参数
  const requestParams = { ...defaultParams, ...params };
  
  return new Promise((resolve, reject) => {
    uni.request({
      url: 'https://fc-mp-0c81a8be-aa9a-4fae-8d6c-54b797768401.next.bspapp.com/cloudfunctions/proxyRequest',
      method: 'POST',
      header: {
        'content-type': 'application/json'
      },
      data: {
        url: 'https://api.saas.changxiaoer.cn/consumer/price/front',
        method: 'POST',
        data: requestParams,
        headers: {
          'content-type': 'application/json',
          'cxe-security-code': 'a45ef582fccf43db9b5c4254c2e33600'
        }
      },
      success: (res) => {
        if (res.statusCode === 200) {
          resolve(res.data.data);
        } else {
          reject(new Error(`请求失败: ${res.statusCode}`));
        }
      }, 
      fail: (err) => {
        reject(new Error(`网络错误: ${err.errMsg}`));
      }
    });
  });
}

/**
 * 获取数据源列表
 * @returns {Promise} 请求Promise
 */
export function getDataSources() {
  return get('/data-sources');
}

/**
 * 更新数据源状态
 * @param {number} id - 数据源ID
 * @param {boolean} enabled - 是否启用
 * @returns {Promise} 请求Promise
 */
export function updateDataSourceStatus(id, enabled) {
  return put(`/data-sources/${id}`, { enabled });
}

/**
 * 获取向阳雅园校区场地预约设置
 * @param {Object} params - 查询参数 { basicId, merchantId, userId, reserveDate }
 * @returns {Promise} 请求Promise
 */
export function getXiangYangYaYuanVenueSettings(params = {}) {
  // 设置默认参数
  const defaultParams = {
    basicId: "403150429",
    merchantId: "10166",
    userId: "",
    reserveDate: "2025-08-13"
  };
  
  // 合并参数
  const requestParams = { ...defaultParams, ...params };
  
  return new Promise((resolve, reject) => {
    uni.request({
      url: 'https://fc-mp-0c81a8be-aa9a-4fae-8d6c-54b797768401.next.bspapp.com/cloudfunctions/proxyRequest',
      method: 'POST',
      header: {
        'content-type': 'application/json'
      },
      data: {
        url: 'https://api.saas.changxiaoer.cn/consumer/price/front',
        method: 'POST',
        data: requestParams,
        headers: {
          'content-type': 'application/json',
          'cxe-security-code': 'a45ef582fccf43db9b5c4254c2e33600'
        }
      },
      success: (res) => {
        if (res.statusCode === 200) {
          resolve(res.data.data);
        } else {
          reject(new Error(`请求失败: ${res.statusCode}`));
        }
      }, 
      fail: (err) => {
        reject(new Error(`网络错误: ${err.errMsg}`));
      }
    });
  });
}

/**
 * 获取向阳33小镇校区场地预约设置
 * @param {Object} params - 查询参数 { basicId, merchantId, userId, reserveDate }
 * @returns {Promise} 请求Promise
 */
export function getXiangYang33VenueSettings(params = {}) {
  // 设置默认参数
  const defaultParams = {
    basicId: "403143353",
    merchantId: "10166",
    userId: "",
    reserveDate: "2025-08-13"
  };
  
  // 合并参数
  const requestParams = { ...defaultParams, ...params };
  
  return new Promise((resolve, reject) => {
    uni.request({
      url: 'https://fc-mp-0c81a8be-aa9a-4fae-8d6c-54b797768401.next.bspapp.com/cloudfunctions/proxyRequest',
      method: 'POST',
      header: {
        'content-type': 'application/json'
      },
      data: {
        url: 'https://api.saas.changxiaoer.cn/consumer/price/front',
        method: 'POST',
        data: requestParams,
        headers: {
          'content-type': 'application/json',
          'cxe-security-code': 'a45ef582fccf43db9b5c4254c2e33600'
        }
      },
      success: (res) => {
        if (res.statusCode === 200) {
          resolve(res.data.data);
        } else {
          reject(new Error(`请求失败: ${res.statusCode}`));
        }
      }, 
      fail: (err) => {
        reject(new Error(`网络错误: ${err.errMsg}`));
      }
    });
  });
}

/**
 * 获取向阳星河城校区场地预约设置
 * @param {Object} params - 查询参数 { basicId, merchantId, userId, reserveDate }
 * @returns {Promise} 请求Promise
 */
export function getXiangYangXingHeChengVenueSettings(params = {}) {
  // 设置默认参数
  const defaultParams = {
    basicId: "403102307",
    merchantId: "10166",
    userId: "",
    reserveDate: "2025-08-13"
  };
  
  // 合并参数
  const requestParams = { ...defaultParams, ...params };
  
  return new Promise((resolve, reject) => {
    uni.request({
      url: 'https://fc-mp-0c81a8be-aa9a-4fae-8d6c-54b797768401.next.bspapp.com/cloudfunctions/proxyRequest',
      method: 'POST',
      header: {
        'content-type': 'application/json'
      },
      data: {
        url: 'https://api.saas.changxiaoer.cn/consumer/price/front',
        method: 'POST',
        data: requestParams,
        headers: {
          'content-type': 'application/json',
          'cxe-security-code': 'a45ef582fccf43db9b5c4254c2e33600'
        }
      },
      success: (res) => {
        if (res.statusCode === 200) {
          resolve(res.data.data);
        } else {
          reject(new Error(`请求失败: ${res.statusCode}`));
        }
      }, 
      fail: (err) => {
        reject(new Error(`网络错误: ${err.errMsg}`));
      }
    });
  });
}

/**
 * 获取爱动金丰网球俱乐部场地预约设置
 * @param {Object} params - 查询参数 { userId, projectUid, dateTime }
 * @returns {Promise} 请求Promise
 */
export function getAiDongJinFengVenueSettings(params = {}) {
  // 设置默认参数
  const defaultParams = {
    userId: 5554966,
    projectUid: "0",
    dateTime: "2025-08-13"
  };
  
  // 合并参数
  const requestParams = { ...defaultParams, ...params };
  
  return new Promise((resolve, reject) => {
    uni.request({
      url: 'https://fc-mp-0c81a8be-aa9a-4fae-8d6c-54b797768401.next.bspapp.com/cloudfunctions/proxyRequest',
      method: 'POST',
      header: {
        'content-type': 'application/json'
      },
      data: {
        url: 'https://wxservice-stg48.pospal.cn/wxapi/AppointmentVenue/LoadValidClassRoomApptSettingV2',
        method: 'POST',
        data: requestParams,
        headers: {
          'PSPLVISITORAUTO': 'API',
          'PSPLVISITORID': 'D1xRCA0+UmAEMQEzCDYIawAzAjRdPwFgUWcGMAdvVzAPaVczWDIAMAVpBjgLZQ08BzACNwlkC2YHOwtvXGFVMQ8+UWY=',
          'APPTYPE': '1',
          'Content-Type': 'application/json',
          'VERSIONINFO': 'NC|2025.02.17',
          'STOREID': '5554966'
        }
      },
      success: (res) => {
        if (res.statusCode === 200) {
          resolve(res.data.data);
        } else {
          reject(new Error(`请求失败: ${res.statusCode}`));
        }
      }, 
      fail: (err) => {
        reject(new Error(`网络错误: ${err.errMsg}`));
      }
    });
  });
}

/**
 * 获取卓乐网球俱乐部场地预约设置
 * @param {Object} params - 查询参数 { dateTime }
 * @returns {Promise} 请求Promise
 */
export function getZhuoLeTennisVenueSettings(params = {}) {
  // 设置默认参数，userId和projectUid固定
  const defaultParams = {
    userId: 5786253,
    projectUid: "1735800065527617183",
    dateTime: "2025-08-19"
  };
  
  // 合并参数
  const requestParams = { ...defaultParams, ...params };
  
  return new Promise((resolve, reject) => {
    uni.request({
      url: 'https://fc-mp-0c81a8be-aa9a-4fae-8d6c-54b797768401.next.bspapp.com/cloudfunctions/proxyRequest',
      method: 'POST',
      header: {
        'content-type': 'application/json'
      },
      data: {
        url: 'https://wxservice-stg48.pospal.cn/wxapi/AppointmentVenue/LoadValidClassRoomApptSettingV2',
        method: 'POST',
        data: requestParams,
        headers: {
          'PSPLVISITORAUTO': 'API',
          'PSPLVISITORID': 'Dl0FXF82VjxWYwQ/DTYNOAcwD29YZQ5uA2IAYQZuX2oEZ1RqDmQDZwBjAjEONA07BzZSNVw/DG0DZ1FiUj0FYw47BTE=',
          'APPTYPE': '1',
          'Content-Type': 'application/json',
          'VERSIONINFO': 'NC|2025.01.01',
          'STOREID': '5786253'
        }
      },
      success: (res) => {
        if (res.statusCode === 200) {
          resolve(res.data.data);
        } else {
          reject(new Error(`请求失败: ${res.statusCode}`));
        }
      }, 
      fail: (err) => {
        reject(new Error(`网络错误: ${err.errMsg}`));
      }
    });
  });
}

/**
 * 获取爱力网球俱乐部场地预约设置
 * @param {Object} params - 查询参数 { dateTime }
 * @returns {Promise} 请求Promise
 */
export function getAiLiVenueSettings(params = {}) {
  // 设置默认参数，userId和projectUid固定
  const defaultParams = {
    userId: 5900824,
    projectUid: "1751942352901414898",
    dateTime: "2025-08-20"
  };
  
  // 合并参数
  const requestParams = { ...defaultParams, ...params };
  
  return new Promise((resolve, reject) => {
    uni.request({
      url: 'https://fc-mp-0c81a8be-aa9a-4fae-8d6c-54b797768401.next.bspapp.com/cloudfunctions/proxyRequest',
      method: 'POST',
      header: {
        'content-type': 'application/json'
      },
      data: {
        url: 'https://wxservice-stg48.pospal.cn/wxapi/AppointmentVenue/LoadValidClassRoomApptSettingV2',
        method: 'POST',
        data: requestParams,
        headers: {
          'PSPLVISITORAUTO': 'API',
          'PSPLVISITORID': 'Dl0FXF82VjxWYwQ/DTYNOAcwD29YZQ5uA2IAYQZuX2oEZ1RqDmQDZwBjAjEONA07BzZSNVw/DG0DZ1FiUj0FYw47BTE=',
          'APPTYPE': '1',
          'Content-Type': 'application/json',
          'VERSIONINFO': 'NC|2025.01.01',
          'STOREID': '5786253'
        }
      },
      success: (res) => {
        if (res.statusCode === 200) {
          resolve(res.data.data);
        } else {
          reject(new Error(`请求失败: ${res.statusCode}`));
        }
      }, 
      fail: (err) => {
        reject(new Error(`网络错误: ${err.errMsg}`));
      }
    });
  });
}

/**
 * 获取3.5+网球（新基）场地基本信息
 * @param {Object} params - 查询参数 { sportHallId, page, limit, whetherOpenUse }
 * @returns {Promise} 请求Promise
 */
export function getDiSaiGroundPage(params = {}) {
  // 设置默认参数
  const defaultParams = {
    sportHallId: "7",
    page: 1,
    limit: -1,
    whetherOpenUse: 1
  };
  
  // 合并参数
  const requestParams = { ...defaultParams, ...params };
  
  return new Promise((resolve, reject) => {
    uni.request({
      url: 'https://fc-mp-0c81a8be-aa9a-4fae-8d6c-54b797768401.next.bspapp.com/cloudfunctions/proxyRequest',
      method: 'POST',
      header: {
        'content-type': 'application/json'
      },
      data: {
        url: 'https://xiaonengshou.com.cn/parent-api/predetermineSite/queryGroundPage',
        method: 'POST',
        data: requestParams,
        headers: {
          'Content-Type': 'application/json'
        }
      },
      success: (res) => {
        if (res.statusCode === 200) {
          resolve(res.data.data);
        } else {
          reject(new Error(`请求失败: ${res.statusCode}`));
        }
      }, 
      fail: (err) => {
        reject(new Error(`网络错误: ${err.errMsg}`));
      }
    });
  });
}

/**
 * 获取3.5+网球（新基）场地预定信息
 * @param {Object} params - 查询参数 { sportHallId, startDate, endDate, page, limit }
 * @returns {Promise} 请求Promise
 */
export function getDiSaiGroundUsePage(params = {}) {
  // 设置默认参数
  const defaultParams = {
    sportHallId: "7",
    startDate: "2025-08-21 00:00:00",
    endDate: "2025-08-22 00:00:00",
    page: 1,
    limit: -1
  };
  
  // 合并参数
  const requestParams = { ...defaultParams, ...params };
  
  return new Promise((resolve, reject) => {
    uni.request({
      url: 'https://fc-mp-0c81a8be-aa9a-4fae-8d6c-54b797768401.next.bspapp.com/cloudfunctions/proxyRequest',
      method: 'POST',
      header: {
        'content-type': 'application/json'
      },
      data: {
        url: 'https://xiaonengshou.com.cn/parent-api/predetermineSite/queryGroundUsePage',
        method: 'POST',
        data: requestParams,
        headers: {
          'Content-Type': 'application/json'
        }
      },
      success: (res) => {
        if (res.statusCode === 200) {
          resolve(res.data.data);
        } else {
          reject(new Error(`请求失败: ${res.statusCode}`));
        }
      }, 
      fail: (err) => {
        reject(new Error(`网络错误: ${err.errMsg}`));
      }
    });
  });
}

/**
 * 获取3.5+网球（金色华庭店）场地基本信息
 * @param {Object} params - 查询参数 { sportHallId, page, limit, whetherOpenUse }
 * @returns {Promise} 请求Promise
 */
export function getJinSeHuaTingGroundPage(params = {}) {
  // 设置默认参数
  const defaultParams = {
    sportHallId: "8",
    page: 1,
    limit: -1,
    whetherOpenUse: 1
  };
  
  // 合并参数
  const requestParams = { ...defaultParams, ...params };
  
  return new Promise((resolve, reject) => {
    uni.request({
      url: 'https://fc-mp-0c81a8be-aa9a-4fae-8d6c-54b797768401.next.bspapp.com/cloudfunctions/proxyRequest',
      method: 'POST',
      header: {
        'content-type': 'application/json'
      },
      data: {
        url: 'https://xiaonengshou.com.cn/parent-api/predetermineSite/queryGroundPage',
        method: 'POST',
        data: requestParams,
        headers: {
          'Content-Type': 'application/json'
        }
      },
      success: (res) => {
        if (res.statusCode === 200) {
          resolve(res.data.data);
        } else {
          reject(new Error(`请求失败: ${res.statusCode}`));
        }
      }, 
      fail: (err) => {
        reject(new Error(`网络错误: ${err.errMsg}`));
      }
    });
  });
}

/**
 * 获取3.5+网球（金色华庭店）场地预定信息
 * @param {Object} params - 查询参数 { sportHallId, startDate, endDate, page, limit }
 * @returns {Promise} 请求Promise
 */
export function getJinSeHuaTingGroundUsePage(params = {}) {
  // 设置默认参数
  const defaultParams = {
    sportHallId: "8",
    startDate: "2025-08-21 00:00:00",
    endDate: "2025-08-22 00:00:00",
    page: 1,
    limit: -1
  };
  
  // 合并参数
  const requestParams = { ...defaultParams, ...params };
  
  return new Promise((resolve, reject) => {
    uni.request({
      url: 'https://fc-mp-0c81a8be-aa9a-4fae-8d6c-54b797768401.next.bspapp.com/cloudfunctions/proxyRequest',
      method: 'POST',
      header: {
        'content-type': 'application/json'
      },
      data: {
        url: 'https://xiaonengshou.com.cn/parent-api/predetermineSite/queryGroundUsePage',
        method: 'POST',
        data: requestParams,
        headers: {
          'Content-Type': 'application/json'
        }
      },
      success: (res) => {
        if (res.statusCode === 200) {
          resolve(res.data.data);
        } else {
          reject(new Error(`请求失败: ${res.statusCode}`));
        }
      }, 
      fail: (err) => {
        reject(new Error(`网络错误: ${err.errMsg}`));
      }
    });
  });
}

/**
 * 获取为傲网球（香树店）场地预定信息
 * @param {Object} params - 查询参数 { companyId, storeId, customerId, motionCusId, rentVenueId, rentAreaId, calendar }
 * @returns {Promise} 请求Promise
 */
export function getWeiAoVenueSettings(params = {}) {
  // 设置默认参数
  const defaultParams = {
    companyId: "4609",
    storeId: "5042",
    customerId: "3604632",
    motionCusId: "",
    rentVenueId: "863",
    rentAreaId: "2156",
    calendar: "2025-09-03"
  };
  
  // 合并参数
  const requestData = { ...defaultParams, ...params };
  
  // 手动构建查询字符串
  const queryString = Object.keys(requestData)
    .map(key => `${encodeURIComponent(key)}=${encodeURIComponent(requestData[key])}`)
    .join('&');
  const url = `https://club.lirenos.com//api/vip/rent/period/oneDay/get/batch/new?${queryString}`;
  
  return new Promise((resolve, reject) => {
    uni.request({
      url: 'https://fc-mp-0c81a8be-aa9a-4fae-8d6c-54b797768401.next.bspapp.com/cloudfunctions/proxyRequest',
      method: 'POST',
      data: {
        url: url,
        method: 'GET',
        headers: {
          'Content-Type': 'application/json',
          'token': 'customertoken@625ae119-a2ec-46b8-b4f7-3c1b1e766a11'
        }
      },
      success: (res) => {
        resolve(res.data.data);
      },
      fail: (err) => {
        reject(err);
      }
    });
  });
}

/**
 * 获取月击网球（丰泰校区）场地预约设置
 * @param {Object} params - 查询参数 { id, date, page, size }
 * @returns {Promise} 请求Promise
 */
export function getYueJiFengTaiVenueSettings(params = {}) {
  // 设置默认参数
  const defaultParams = {
    id: "2982889030025338",
    date: "2025/09/08",
    page: 1,
    size: 10
  };
  
  // 合并参数
  const requestData = { ...defaultParams, ...params };
  
  // 手动构建查询字符串
  const queryString = Object.keys(requestData)
    .map(key => `${encodeURIComponent(key)}=${encodeURIComponent(requestData[key])}`)
    .join('&');
  const url = `https://stmember.styd.cn/v1/venues/venues_site_list?${queryString}`;
  
  return new Promise((resolve, reject) => {
    uni.request({
      url: 'https://fc-mp-0c81a8be-aa9a-4fae-8d6c-54b797768401.next.bspapp.com/cloudfunctions/proxyRequest',
      method: 'POST',
      header: {
        'content-type': 'application/json'
      },
      data: {
        url: url,
        method: 'GET',
        data: {},
        headers: {
          'Content-Type': 'application/json',
          'shop-id': '2375138188913821',
          'brand-code': '1ql4d19ZneO',
          'app-id': 'mina',
          'mina-version': 'independent'
        }
      },
      success: (res) => {
        if (res.statusCode === 200) {
          resolve(res.data.data);
        } else {
          reject(new Error(`请求失败: ${res.statusCode}`));
        }
      }, 
      fail: (err) => {
        reject(new Error(`网络错误: ${err.errMsg}`));
      }
    });
  });
}

/**
 * 获取月击网球（电商园校区）场地预约设置
 * @param {Object} params - 查询参数 { id, date, page, size }
 * @returns {Promise} 请求Promise
 */
export function getYueJiDianShangYuanVenueSettings(params = {}) {
  // 设置默认参数
  const defaultParams = {
    id: "2803019859755125",
    date: "2025/09/08",
    page: 1,
    size: 10
  };
  
  // 合并参数
  const requestData = { ...defaultParams, ...params };
  
  // 手动构建查询字符串
  const queryString = Object.keys(requestData)
    .map(key => `${encodeURIComponent(key)}=${encodeURIComponent(requestData[key])}`)
    .join('&');
  const url = `https://stmember.styd.cn/v1/venues/venues_site_list?${queryString}`;
  
  return new Promise((resolve, reject) => {
    uni.request({
      url: 'https://fc-mp-0c81a8be-aa9a-4fae-8d6c-54b797768401.next.bspapp.com/cloudfunctions/proxyRequest',
      method: 'POST',
      header: {
        'content-type': 'application/json'
      },
      data: {
        url: url,
        method: 'GET',
        data: {},
        headers: {
          'Content-Type': 'application/json',
          'shop-id': '2375138188913821',
          'brand-code': '1ql4d19ZneO',
          'app-id': 'mina',
          'mina-version': 'independent'
        }
      },
      success: (res) => {
        if (res.statusCode === 200) {
          resolve(res.data.data);
        } else {
          reject(new Error(`请求失败: ${res.statusCode}`));
        }
      }, 
      fail: (err) => {
        reject(new Error(`网络错误: ${err.errMsg}`));
      }
    });
  });
}

/**
 * 获取月击网球（虎门大道校区）场地预约设置
 * @param {Object} params - 查询参数 { id, date, page, size }
 * @returns {Promise} 请求Promise
 */
export function getYueJiHuMenDaDaoVenueSettings(params = {}) {
  // 设置默认参数
  const defaultParams = {
    id: "2803022711881772",
    date: "2025/09/08",
    page: 1,
    size: 10
  };
  
  // 合并参数
  const requestData = { ...defaultParams, ...params };
  
  // 手动构建查询字符串
  const queryString = Object.keys(requestData)
    .map(key => `${encodeURIComponent(key)}=${encodeURIComponent(requestData[key])}`)
    .join('&');
  const url = `https://stmember.styd.cn/v1/venues/venues_site_list?${queryString}`;
  
  return new Promise((resolve, reject) => {
    uni.request({
      url: 'https://fc-mp-0c81a8be-aa9a-4fae-8d6c-54b797768401.next.bspapp.com/cloudfunctions/proxyRequest',
      method: 'POST',
      header: {
        'content-type': 'application/json'
      },
      data: {
        url: url,
        method: 'GET',
        data: {},
        headers: {
          'Content-Type': 'application/json',
          'shop-id': '2375138188913821',
          'brand-code': '1ql4d19ZneO',
          'app-id': 'mina',
          'mina-version': 'independent'
        }
      },
      success: (res) => {
        if (res.statusCode === 200) {
          resolve(res.data.data);
        } else {
          reject(new Error(`请求失败: ${res.statusCode}`));
        }
      }, 
      fail: (err) => {
        reject(new Error(`网络错误: ${err.errMsg}`));
      }
    });
  });
}

export default {
  request,
  get,
  post,
  put,
  del,
  getVenueList,
  getVenueDetail,
  getZhuoLeVenueSettings,
  getDataSources,
  updateDataSourceStatus,
  getXiangYangYaYuanVenueSettings,
  getXiangYang33VenueSettings,
  getXiangYangXingHeChengVenueSettings,
  getXiangYangZhenXingChengVenueSettings,
  getTuoDeVenueSettings,
  getAiDongJinFengVenueSettings,
  getZhuoLeTennisVenueSettings,
  getAiLiVenueSettings,
  getDongChengVenueSettings,
  getDongGuanSportsCenterVenueSettings,
  getDiSaiGroundPage,
  getDiSaiGroundUsePage,
  getJinSeHuaTingGroundPage,
  getJinSeHuaTingGroundUsePage,
  getWeiAoVenueSettings,
  getFuDiVenueSettings,
  getBuJiVenueSettings,
  getYuanFengVenueSettings,
  getYueJiVenueSettings,
  getYueJiFengTaiVenueSettings,
  getYueJiDianShangYuanVenueSettings,
  getYueJiHuMenDaDaoVenueSettings,
  getTaiLuGeVenueSettings,
  getSongShanHuTaiLuGeVenueSettings,
  getLuoJieGroundPage,
  getLuoJieGroundUsePage,
  getShengXuanZhiXingVenueSettings,
  getShengXuanDaZhuangVenueSettings,
  getUPTennisSanXiSKYVenueSettings,
  getKuaiKeVenueSettings,
  getJinManGuanVenueSettings,
  getJinManGuanPaZhouVenueSettings,
  getJinManGuanWeiSiTingVenueSettings,
  getJinManGuanHuangGuanVenueSettings,
  getJinManGuanHaiZhuVenueSettings,
  getJinManGuanHuaGongBeiVenueSettings,
  getJinManGuanHuaGongXiVenueSettings,
  getJinManGuanPanJiangHuaYuanVenueSettings,
  getJinManGuanTianHeChengVenueSettings,
  getJinManGuanHuaGongDaXueChengVenueSettings,
  getJinManGuanHuaMeiLuHuVenueSettings,
  getJinManGuanHuaMeiXueXiaoVenueSettings,
  getJinManGuanZhuJiangXinChengVenueSettings,
  getJinManGuanBaiYunVenueSettings,
  getJinManGuanQiFengShanVenueSettings,
  getHuaGuoShanVenueSettings,
  getJinLinShanZhuangVenueSettings,
  getYuFengWeiJiangBianVenueSettings,
  getFengTaiHuaYuanVenueSettings,
  getTuoPuNanGuoHuaYuanVenueSettings,
  getTuoPuWanShengWeiVenueSettings,
  getTuoPuXinGangDongVenueSettings,
  getTuoPuBaiYunHuJinBoTianDiVenueSettings,
  getJianChaoTennisVenueSettings,
  getQingYunTennisVenueSettings,
  getQuanAiLiWanVenueSettings,
  getYunBaoLuoLunSiVenueSettings,
  getHanWeiTennisVenueSettings,
  getMteamJiaHeGuangFengVenueSettings,
  getMteamHuangPuVenueSettings,
  generateKuaiKeApiSignature
};

/**
 * 获取向阳振兴城校区场地预约设置
 * @param {Object} params - 查询参数 { basicId, merchantId, userId, reserveDate }
 * @returns {Promise} 请求Promise
 */
export function getXiangYangZhenXingChengVenueSettings(params = {}) {
  // 设置默认参数
  const defaultParams = {
    basicId: "403160622",
    merchantId: "10166",
    userId: "",
    reserveDate: "2025-08-13"
  };
  
  // 合并参数
  const requestParams = { ...defaultParams, ...params };
  
  return new Promise((resolve, reject) => {
    uni.request({
      url: 'https://fc-mp-0c81a8be-aa9a-4fae-8d6c-54b797768401.next.bspapp.com/cloudfunctions/proxyRequest',
      method: 'POST',
      header: {
        'content-type': 'application/json'
      },
      data: {
        url: 'https://api.saas.changxiaoer.cn/consumer/price/front',
        method: 'POST',
        data: requestParams,
        headers: {
          'content-type': 'application/json',
          'cxe-security-code': 'a45ef582fccf43db9b5c4254c2e33600'
        }
      },
      success: (res) => {
        if (res.statusCode === 200) {
          resolve(res.data.data);
        } else {
          reject(new Error(`请求失败: ${res.statusCode}`));
        }
      }, 
      fail: (err) => {
        reject(new Error(`网络错误: ${err.errMsg}`));
      }
    });
  });
}

/**
 * 获取拓德网球俱乐部场地预约设置
 * @param {Object} params - 查询参数 { basicId, merchantId, userId, reserveDate }
 * @returns {Promise} 请求Promise
 */
export function getTuoDeVenueSettings(params = {}) {
  // 设置默认参数
  const defaultParams = {
    basicId: "2112235080",
    merchantId: "10293",
    userId: "",
    reserveDate: "2025-08-13"
  };
  
  // 合并参数
  const requestParams = { ...defaultParams, ...params };
  
  return new Promise((resolve, reject) => {
    uni.request({
      url: 'https://fc-mp-0c81a8be-aa9a-4fae-8d6c-54b797768401.next.bspapp.com/cloudfunctions/proxyRequest',
      method: 'POST',
      header: {
        'content-type': 'application/json'
      },
      data: {
        url: 'https://api.saas.changxiaoer.cn/consumer/price/front',
        method: 'POST',
        data: requestParams,
        headers: {
          'content-type': 'application/json',
          'cxe-security-code': '499902fbd32341cb83ea8964814b99ee'
        }
      },
      success: (res) => {
        if (res.statusCode === 200) {
          resolve(res.data.data);
        } else {
          reject(new Error(`请求失败: ${res.statusCode}`));
        }
      }, 
      fail: (err) => {
        reject(new Error(`网络错误: ${err.errMsg}`));
      }
    });
  });
}

/**
 * 获取东城体育公园场地预约设置
 * @param {Object} params - 查询参数 { gym_id, type, filter_front_reserve, date }
 * @returns {Promise} 请求Promise
 */
export function getDongChengVenueSettings(params = {}) {
  // 设置默认参数
  const defaultParams = {
    gym_id: 1,
    type: 'site',
    filter_front_reserve: 0,
    date: '2025-8-20'
  };
  
  // 合并参数
  const requestData = { ...defaultParams, ...params };
  
  // 手动构建查询字符串
  const queryString = Object.keys(requestData)
    .map(key => `${encodeURIComponent(key)}=${encodeURIComponent(requestData[key])}`)
    .join('&');
  const url = `https://api.dctygy.cn/api/wechat/gym/reserve?${queryString}`;
  
  return new Promise((resolve, reject) => {
    uni.request({
      url: 'https://fc-mp-0c81a8be-aa9a-4fae-8d6c-54b797768401.next.bspapp.com/cloudfunctions/proxyRequest',
      method: 'POST',
      data: {
        url: url,
        method: 'GET',
        headers: {
          'Authorization': 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyIjoie1widXNlcl9pZFwiOjE1MjR9IiwiZXhwIjoxNzU2MTkzODM2fQ.HOLeFkmFMSNe1bC6_OZFYVtSW-oWSYWXypOAVK50wwg',
          'Content-Type': 'application/json'
        }
      },
      success: (res) => {
        resolve(res.data.data);
      },
      fail: (err) => {
        reject(err);
      }
    });
  });
}



/**
 * 获取东莞市体育中心场地预约设置
 * @param {Object} params - 查询参数 { gym_id, type, date }
 * @returns {Promise} 请求Promise
 */
export function getDongGuanSportsCenterVenueSettings(params = {}) {
  // 设置默认参数
  const defaultParams = {
    gym_id: 5,
    type: 'site',
    date: '2025-8-19'
  };
  
  // 合并参数
  const requestData = { ...defaultParams, ...params };
  
  // 手动构建查询字符串
  const queryString = Object.keys(requestData)
    .map(key => `${encodeURIComponent(key)}=${encodeURIComponent(requestData[key])}`)
    .join('&');
  const url = `https://api.dgstyzx.com/api/wechat/gym/reserve?${queryString}`;
  
  return new Promise((resolve, reject) => {
    uni.request({
      url: 'https://tonightwheretoplay-1-g8926095.tcb.qcloud.la/proxy',
      method: 'POST',
      data: {
        url: url,
        method: 'GET',
        headers: {
          'Authorization': 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyIjoie1widXNlcl9pZFwiOjEyMjE5fSIsImV4cCI6MTc1NTY4MTIyMH0.Q7cs173QOt3A6AJAhDhoxIUk-3PcXn-Q0oYUdKlRJwM',
          'Content-Type': 'application/json'
        }
      },
      success: (res) => {
        resolve(res);
      },
      fail: (err) => {
        reject(err);
      }
    });
  });
}



/**
 * 获取3.5+网球（福地）场地预约设置
 * @param {Object} params - 查询参数 { date, deskTypeId, shopId, shopName, token }
 * @returns {Promise} 请求Promise
 */
export function getFuDiVenueSettings(params = {}) {
  // 设置默认参数
  const defaultParams = {
    date: "2025-09-02",
    deskTypeId: "463560331927552",
    shopId: "455834640958464",
    shopName: "3.5+网球运动馆",
    token: ""
  };
  
  // 合并参数
  const requestData = { ...defaultParams, ...params };
  
  return new Promise((resolve, reject) => {
    uni.request({
      url: 'https://fc-mp-0c81a8be-aa9a-4fae-8d6c-54b797768401.next.bspapp.com/cloudfunctions/proxyRequest',
      method: 'POST',
      header: {
        'content-type': 'application/json'
      },
      data: {
        url: 'https://room.yunvip123.cn/prod-api/room/smallProgram/bookingBoard',
        method: 'POST',
        data: requestData,
        headers: {
          'Content-Type': 'application/json'
        }
      },
      success: (res) => {
        if (res.statusCode === 200) {
          resolve(res.data.data);
        } else {
          reject(new Error(`请求失败: ${res.statusCode}`));
        }
      }, 
      fail: (err) => {
        reject(new Error(`网络错误: ${err.errMsg}`));
      }
    });
  });
}

/**
 * 获取埗击网球场地预约设置
 * @param {Object} params - 查询参数 { userId, projectUid, dateTime }
 * @returns {Promise} 请求Promise
 */
export function getBuJiVenueSettings(params = {}) {
  return new Promise((resolve, reject) => {
    uni.request({
      url: 'https://fc-mp-0c81a8be-aa9a-4fae-8d6c-54b797768401.next.bspapp.com/cloudfunctions/proxyRequest',
      method: 'POST',
      header: {
        'content-type': 'application/json'
      },
      data: {
        url: 'https://wxservice-stg48.pospal.cn/wxapi/AppointmentVenue/LoadValidClassRoomApptSettingV2',
        method: 'POST',
        data: params,
        headers: {
          'PSPLVISITORAUTO': 'API',
          'APPTYPE': '1',
          'VERSIONINFO': 'NC|2025.02.28',
          'STOREID': '5710920'
        }
      },
      success: (res) => {
        if (res.statusCode === 200) {
          resolve(res.data.data);
        } else {
          reject(new Error(`请求失败: ${res.statusCode}`));
        }
      }, 
      fail: (err) => {
        reject(new Error(`网络错误: ${err.errMsg}`));
      }
    });
  });
}

/**
 * 获取源峰网球场地预约设置
 * @param {Object} params - 查询参数 { userId, projectUid, dateTime }
 * @returns {Promise} 请求Promise
 */
export function getYuanFengVenueSettings(params = {}) {
  return new Promise((resolve, reject) => {
    uni.request({
      url: 'https://fc-mp-0c81a8be-aa9a-4fae-8d6c-54b797768401.next.bspapp.com/cloudfunctions/proxyRequest',
      method: 'POST',
      header: {
        'content-type': 'application/json'
      },
      data: {
        url: 'https://wxservice-stg48.pospal.cn/wxapi/AppointmentVenue/LoadValidClassRoomApptSettingV2',
        method: 'POST',
        data: params,
        headers: {
          'PSPLVISITORAUTO': 'API',
          'APPTYPE': '1',
          'VERSIONINFO': 'NC|2025.02.28',
          'STOREID': '5871935'
        }
      },
      success: (res) => {
        if (res.statusCode === 200) {
          resolve(res.data.data);
        } else {
          reject(new Error(`请求失败: ${res.statusCode}`));
        }
      }, 
      fail: (err) => {
        reject(new Error(`网络错误: ${err.errMsg}`));
      }
    });
  });
}

/**
 * 获取罗杰网球场地基本信息
 * @param {Object} params - 查询参数 { sportHallId }
 * @returns {Promise} 请求Promise
 */
export function getLuoJieGroundPage(params = {}) {
  // 设置默认参数
  const defaultParams = {
    sportHallId: "17"
  };
  
  // 合并参数
  const requestData = { ...defaultParams, ...params };
  
  return new Promise((resolve, reject) => {
    uni.request({
      url: 'https://fc-mp-0c81a8be-aa9a-4fae-8d6c-54b797768401.next.bspapp.com/cloudfunctions/proxyRequest',
      method: 'POST',
      header: {
        'content-type': 'application/json'
      },
      data: {
        url: 'https://xiaonengshou.com.cn/parent-api/predetermineSite/queryGroundPage',
        method: 'POST',
        data: requestData,
        headers: {
          'Content-Type': 'application/json'
        }
      },
      success: (res) => {
        if (res.statusCode === 200) {
          resolve(res.data.data);
        } else {
          reject(new Error(`请求失败: ${res.statusCode}`));
        }
      }, 
      fail: (err) => {
        reject(new Error(`网络错误: ${err.errMsg}`));
      }
    });
  });
}

/**
 * 获取罗杰网球场地使用信息
 * @param {Object} params - 查询参数 { sportHallId, startDate, endDate }
 * @returns {Promise} 请求Promise
 */
export function getLuoJieGroundUsePage(params = {}) {
  // 设置默认参数
  const defaultParams = {
    sportHallId: "17",
    startDate: "",
    endDate: ""
  };
  
  // 合并参数
  const requestData = { ...defaultParams, ...params };
  
  return new Promise((resolve, reject) => {
    uni.request({
      url: 'https://fc-mp-0c81a8be-aa9a-4fae-8d6c-54b797768401.next.bspapp.com/cloudfunctions/proxyRequest',
      method: 'POST',
      header: {
        'content-type': 'application/json'
      },
      data: {
        url: 'https://xiaonengshou.com.cn/parent-api/predetermineSite/queryGroundUsePage',
        method: 'POST',
        data: requestData,
        headers: {
          'Content-Type': 'application/json'
        }
      },
      success: (res) => {
        if (res.statusCode === 200) {
          resolve(res.data.data);
        } else {
          reject(new Error(`请求失败: ${res.statusCode}`));
        }
      }, 
      fail: (err) => {
        reject(new Error(`网络错误: ${err.errMsg}`));
      }
    });
  });
}

/**
 * 获取松山湖太鲁阁公园场地预约设置
 * @param {Object} params - 查询参数 { gym_id, type, date }
 * @returns {Promise} 请求Promise
 */
export function getTaiLuGeVenueSettings(params = {}) {
  // 设置默认参数
  const defaultParams = {
    gym_id: 42,
    type: 'site',
    date: '2025-9-2'
  };
  
  // 合并参数
  const requestData = { ...defaultParams, ...params };
  
  // 手动构建查询字符串
  const queryString = Object.keys(requestData)
    .map(key => `${encodeURIComponent(key)}=${encodeURIComponent(requestData[key])}`)
    .join('&');
  const url = `https://api.sshtyt.cn/api/wechat/gym/reserve?${queryString}`;
  
  return new Promise((resolve, reject) => {
    uni.request({
      url: 'https://fc-mp-0c81a8be-aa9a-4fae-8d6c-54b797768401.next.bspapp.com/cloudfunctions/proxyRequest',
      method: 'POST',
      data: {
        url: url,
        method: 'GET',
        headers: {
          'Authorization': 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyIjoie1widXNlcl9pZFwiOjIwNDI4fSIsImV4cCI6MTc1NzM4NDI3OX0.qoJI6Cxnngc-jKAIhOn_HddrHtfwBu_HWmDAYGCo5e8',
          'Content-Type': 'application/json',
          'xweb_xhr': '1'
        }
      },
      success: (res) => {
        resolve(res);
      },
      fail: (err) => {
        reject(err);
      }
    });
  });
}

/**
 * 获取松山湖太鲁阁公园场地预约设置（备用函数）
 * @param {Object} params - 查询参数 { gym_id, type, date }
 * @returns {Promise} 请求Promise
 */
export function getSongShanHuTaiLuGeVenueSettings(params = {}) {
  // 设置默认参数
  const defaultParams = {
    gym_id: 42,
    type: 'site',
    date: '2025-9-2'
  };
  
  // 合并参数
  const requestData = { ...defaultParams, ...params };
  
  // 手动构建查询字符串
  const queryString = Object.keys(requestData)
    .map(key => `${encodeURIComponent(key)}=${encodeURIComponent(requestData[key])}`)
    .join('&');
  const url = `https://api.sshtyt.cn/api/wechat/gym/reserve?${queryString}`;
  
  return new Promise((resolve, reject) => {
    uni.request({
      url: 'https://fc-mp-0c81a8be-aa9a-4fae-8d6c-54b797768401.next.bspapp.com/cloudfunctions/proxyRequest',
      method: 'POST',
      data: {
        url: url,
        method: 'GET',
        headers: {
          'Authorization': 'eeyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyIjoie1widXNlcl9pZFwiOjIwNDI4fSIsImV4cCI6MTc1ODI1MDYxNH0._rfb2M2UnTaHOTmQfeGyB22fq0iIjjYxJoPO3VmJeqQ',
          'Content-Type': 'application/json',
          'xweb_xhr': '1'
        }
      },
      success: (res) => {
        resolve(res);
      },
      fail: (err) => {
        reject(err);
      }
    });
  });
}

/**
 * 获取月击网球（城市之光校区）场地预约设置
 * @param {Object} params - 查询参数 { id, date, page, size }
 * @returns {Promise} 请求Promise
 */
export function getYueJiVenueSettings(params = {}) {
  // 设置默认参数
  const defaultParams = {
    id: "2883247634186321",
    date: "2025/09/08",
    page: 1,
    size: 10
  };
  
  // 合并参数
  const requestData = { ...defaultParams, ...params };
  
  // 手动构建查询字符串
  const queryString = Object.keys(requestData)
    .map(key => `${encodeURIComponent(key)}=${encodeURIComponent(requestData[key])}`)
    .join('&');
  const url = `https://stmember.styd.cn/v1/venues/venues_site_list?${queryString}`;
  
  return new Promise((resolve, reject) => {
    uni.request({
      url: 'https://fc-mp-0c81a8be-aa9a-4fae-8d6c-54b797768401.next.bspapp.com/cloudfunctions/proxyRequest',
      method: 'POST',
      data: {
        url: url,
        method: 'GET',
        headers: {
          'Content-Type': 'application/json',
          'shop-id': '2375138188913821',
          'brand-code': '1ql4d19ZneO',
          'app-id': 'mina',
          'mina-version': 'independent'
        }
      },
      success: (res) => {
        resolve(res.data.data);
      },
      fail: (err) => {
        reject(err);
      }
    });
  });
}

/**
 * 获取晟旋网球(执信店)场地预约设置
 * @param {Object} params - 查询参数 { date }
 * @returns {Promise} 请求Promise
 */
export function getShengXuanZhiXingVenueSettings(params = {}) {
  // 设置默认参数
  const defaultParams = {
    stadium_id: 12669117443,
    business_id: 12669117442,
    scene_id: 14085814620160,
    date: "2025-10-12"
  };
  
  // 合并参数
  const requestParams = { ...defaultParams, ...params };
  
  return new Promise((resolve, reject) => {
    uni.request({
      url: 'https://fc-mp-0c81a8be-aa9a-4fae-8d6c-54b797768401.next.bspapp.com/cloudfunctions/proxyRequest',
      method: 'POST',
      header: {
        'content-type': 'application/json'
      },
      data: {
        url: 'https://api.d2yun.cn/v2/member/space_resource/list',
        method: 'GET',
        params: requestParams
      },
      success: (res) => {
        if (res.statusCode === 200) {
          resolve(res.data.data);
        } else {
          reject(new Error(`请求失败: ${res.statusCode}`));
        }
      }, 
      fail: (err) => {
        reject(new Error(`网络错误: ${err.errMsg}`));
      }
    });
  });
}

/**
 * 获取锦林山庄网球馆场地预约设置
 * @param {Object} params - 查询参数 { startDate, endDate }
 * @returns {Promise} 请求Promise
 */
export function getJinLinShanZhuangVenueSettings(params = {}) {
  // 设置默认参数
  const defaultParams = {
    timezoneOffset: -480,
    access_token: 'e39767ed07c96f3ae8e92191a10e9e16',
    user_id: '9189184',
    box_id: '18446',
    language: 'zh_CN',
    api_version: '3',
    appId: 'wxc7f3f7975f41f64b',
    id: '10487'
  };
  
  // 合并参数
  const requestParams = { ...defaultParams, ...params };
  
  // 格式化日期参数（如果存在）
  if (requestParams.startDate) {
    if (requestParams.startDate instanceof Date) {
      requestParams.startDate = requestParams.startDate.toString();
    }
  }
  if (requestParams.endDate) {
    if (requestParams.endDate instanceof Date) {
      requestParams.endDate = requestParams.endDate.toString();
    }
  }
  
  // 生成API签名
  const api_signature = generateKuaiKeApiSignature(requestParams, requestParams.appId);
  requestParams.api_signature = api_signature;
  
  return new Promise((resolve, reject) => {
    uni.request({
      url: 'https://fc-mp-0c81a8be-aa9a-4fae-8d6c-54b797768401.next.bspapp.com/cloudfunctions/proxyRequest',
      method: 'POST',
      header: {
        'content-type': 'application/json'
      },
      data: {
        url: 'https://api2.iwod.cn/court/getSubCourtList',
        method: 'GET',
        params: requestParams
      },
      success: (res) => {
        if (res.statusCode === 200) {
          resolve(res.data.data);
        } else {
          reject(new Error(`请求失败: ${res.statusCode}`));
        }
      }, 
      fail: (err) => {
        reject(new Error(`网络错误: ${err.errMsg}`));
      }
    });
  });
}

export function getUPTennisSanXiSKYVenueSettings(params = {}) {
  // 设置默认参数
  const defaultParams = {
    date: new Date().toISOString().split('T')[0].replace(/-/g, '%2F')
  };
  
  // 合并参数
  const requestParams = { ...defaultParams, ...params };
  
  return new Promise((resolve, reject) => {
    // 并发请求两个接口
    Promise.all([
      // 第一个接口请求
      new Promise((resolve1, reject1) => {
        uni.request({
          url: 'https://fc-mp-0c81a8be-aa9a-4fae-8d6c-54b797768401.next.bspapp.com/cloudfunctions/proxyRequest',
          method: 'POST',
          header: {
            'content-type': 'application/json'
          },
          data: {
            url: `https://stmember.styd.cn/v1/venues/venues_site_list?id=3161239744807019&date=${requestParams.date}&page=1&size=10`,
            method: 'GET',
            headers: {
              'Content-Type': 'application/json',
              'shop-id': '3158418387545906',
              'brand-code': 'Dy2VmExdNAM',
              'app-id': 'mina',
              'mina-version': 'independent'
            }
          },
          success: (res) => {
            if (res.statusCode === 200) {
              resolve1(res.data.data);
            } else {
              reject1(new Error(`请求失败: ${res.statusCode}`));
            }
          },
          fail: (err) => {
            reject1(new Error(`网络错误: ${err.errMsg}`));
          }
        });
      }),
      // 第二个接口请求
      new Promise((resolve2, reject2) => {
        uni.request({
          url: 'https://fc-mp-0c81a8be-aa9a-4fae-8d6c-54b797768401.next.bspapp.com/cloudfunctions/proxyRequest',
          method: 'POST',
          header: {
            'content-type': 'application/json'
          },
          data: {
            url: `https://stmember.styd.cn/v1/venues/venues_site_list?id=3313360154722332&date=${requestParams.date}&page=1&size=10`,
            method: 'GET',
            headers: {
              'Content-Type': 'application/json',
              'shop-id': '3158418387545906',
              'brand-code': 'Dy2VmExdNAM',
              'app-id': 'mina',
              'mina-version': 'independent'
            }
          },
          success: (res) => {
            if (res.statusCode === 200) {
              resolve2(res.data.data);
            } else {
              reject2(new Error(`请求失败: ${res.statusCode}`));
            }
          },
          fail: (err) => {
            reject2(new Error(`网络错误: ${err.errMsg}`));
          }
        });
      })
    ]).then(([data1, data2]) => {
      // 合并两个接口的数据
      const mergedData = [data1, data2];
      resolve(mergedData);
    }).catch(reject);
  });
}

/**
 * 获取快客网球场地设置
 * @param {Object} params - 查询参数 { startDate, endDate }
 * @returns {Promise} 请求Promise
 */
export function getKuaiKeVenueSettings(params = {}) {
  // 设置默认参数
  const defaultParams = {
    timezoneOffset: -480,
    access_token: 'a5e38610555fd0ef242b17b80cde58e1',
    user_id: '9176257',
    box_id: '16808',
    language: 'zh_CN',
    api_version: '3',
    appId: 'wxc9475501ea83ac12'
  };
  
  // 创建单个请求的函数
  const makeRequest = (id) => {
    console.log("params",params);
    
    // 合并参数（不包含api_signature）
    const requestParams = { ...defaultParams, ...params, id };
    
    // 生成签名
    const api_signature = generateKuaiKeApiSignature(requestParams, defaultParams.appId);
    
    // 添加签名到参数中
    requestParams.api_signature = api_signature;
    
    return new Promise((resolve, reject) => {
      uni.request({
        url: 'https://fc-mp-0c81a8be-aa9a-4fae-8d6c-54b797768401.next.bspapp.com/cloudfunctions/proxyRequest',
        method: 'POST',
        header: {
          'content-type': 'application/json'
        },
        data: {
          url: 'https://api2.iwod.cn/court/getSubCourtList',
          method: 'GET',
          params: requestParams
        },
        success: (res) => {
          if (res.statusCode === 200) {
            resolve(res.data.data);
          } else {
            reject(new Error(`请求失败: ${res.statusCode}`));
          }
        }, 
        fail: (err) => {
          reject(new Error(`网络错误: ${err.errMsg}`));
        }
      });
    });
  };
  
  // 同时请求两组参数
  return Promise.all([
    makeRequest('9344'),  // 第一组参数
    makeRequest('9721')   // 第二组参数
  ]).then(([result1, result2]) => {
    // 合并两个结果的 courtList
    const mergedResult = {
      ...result1,
      data: {
        ...result1.data,
        data: {
          ...result1.data.data,
          courtList: [
            ...(result1.data.data.courtList || []),
            ...(result2.data.data.courtList || [])
          ]
        }
      }
    };
    
    
    return mergedResult;
  });
}

/**
 * 获取裕丰围江边网球场场地预约设置
 * @param {Object} params - 查询参数 { startDate, endDate }
 * @returns {Promise} 请求Promise
 */
export function getYuFengWeiJiangBianVenueSettings(params = {}) {
  // 设置默认参数
  const defaultParams = {
    timezoneOffset: -480,
    access_token: '8ca5e71f73f4bc86e21f5077f347d220',
    user_id: '9189184',
    box_id: '18647',
    language: 'zh_CN',
    api_version: '3',
    appId: 'wxc7f3f7975f41f64b',
    id: '10622'
  };
  
  // 合并参数（不包含api_signature）
  const requestParams = { ...defaultParams, ...params };
  
  // 格式化日期参数（如果存在）
  if (requestParams.startDate) {
    if (requestParams.startDate instanceof Date) {
      requestParams.startDate = requestParams.startDate.toString();
    }
  }
  if (requestParams.endDate) {
    if (requestParams.endDate instanceof Date) {
      requestParams.endDate = requestParams.endDate.toString();
    }
  }
  
  // 生成签名
  const api_signature = generateKuaiKeApiSignature(requestParams, defaultParams.appId);
  
  // 添加签名到参数中
  requestParams.api_signature = api_signature;
  
  return new Promise((resolve, reject) => {
    uni.request({
      url: 'https://fc-mp-0c81a8be-aa9a-4fae-8d6c-54b797768401.next.bspapp.com/cloudfunctions/proxyRequest',
      method: 'POST',
      header: {
        'content-type': 'application/json'
      },
      data: {
        url: 'https://api2.iwod.cn/court/getSubCourtList',
        method: 'GET',
        params: requestParams
      },
      success: (res) => {
        if (res.statusCode === 200) {
          resolve(res.data.data);
        } else {
          reject(new Error(`请求失败: ${res.statusCode}`));
        }
      }, 
      fail: (err) => {
        reject(new Error(`网络错误: ${err.errMsg}`));
      }
    });
  });
}

/**
 * 获取金满贯(中国大酒店)场地预约设置
 * @param {Object} params - 查询参数 { startDate, endDate }
 * @returns {Promise} 请求Promise
 */
export function getJinManGuanVenueSettings(params = {}) {
  // 设置默认参数
  const defaultParams = {
    timezoneOffset: -480,
    access_token: '778f70c298e7388e5e34353c39964504',
    user_id: '3657085',
    box_id: '7103',
    language: 'zh_CN',
    api_version: '3',
    appId: 'wx43d54f8c2495bdfa',
    id: '1977'
  };
  
  // 合并参数
  const requestParams = { ...defaultParams, ...params };
  
  // 格式化日期参数（如果存在）
  if (requestParams.startDate) {
    if (requestParams.startDate instanceof Date) {
      requestParams.startDate = requestParams.startDate.toISOString().split('T')[0];
    }
  }
  if (requestParams.endDate) {
    if (requestParams.endDate instanceof Date) {
      requestParams.endDate = requestParams.endDate.toISOString().split('T')[0];
    }
  }
  
  // 生成API签名
  const api_signature = generateKuaiKeApiSignature(requestParams, defaultParams.appId);
  requestParams.api_signature = api_signature;
  
  return new Promise((resolve, reject) => {
    uni.request({
      url: 'https://fc-mp-0c81a8be-aa9a-4fae-8d6c-54b797768401.next.bspapp.com/cloudfunctions/proxyRequest',
      method: 'POST',
      header: {
        'content-type': 'application/json'
      },
      data: {
        url: 'https://api2.iwod.cn/court/getSubCourtList',
        method: 'GET',
        params: requestParams
      },
      success: (res) => {
        if (res.statusCode === 200) {
          resolve(res.data.data);
        } else {
          reject(new Error(`请求失败: ${res.statusCode}`));
        }
      },
      fail: (err) => {
        reject(new Error(`网络错误: ${err.errMsg}`));
      }
    });
  });
}
